2024-11-30 23:05:22 +08:00
|
|
|
from configs import dify_config
|
|
|
|
|
|
|
|
|
|
|
|
def apply_gevent_threading_patch():
|
|
|
|
"""
|
|
|
|
Run threading patch by gevent
|
|
|
|
to make standard library threading compatible.
|
|
|
|
Patching should be done as early as possible in the lifecycle of the program.
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
if not dify_config.DEBUG:
|
2024-12-24 18:38:51 +08:00
|
|
|
from gevent import monkey # type: ignore
|
|
|
|
from grpc.experimental import gevent as grpc_gevent # type: ignore
|
2024-11-30 23:05:22 +08:00
|
|
|
|
|
|
|
# gevent
|
|
|
|
monkey.patch_all()
|
|
|
|
|
|
|
|
# grpc gevent
|
|
|
|
grpc_gevent.init_gevent()
|