mirror of
https://github.com/langgenius/dify.git
synced 2026-11-10 21:35:45 +08:00
Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: zhaohao1004 <zhaohao1004@gmail.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: FFXN <lizy@dify.ai>
19 lines
667 B
Python
19 lines
667 B
Python
from gevent.monkey import is_module_patched
|
|
|
|
# Celery patches the stdlib before importing this entrypoint for -P gevent. Prefork workers
|
|
# (including the KnowledgeFS local engine) must retain native subprocess, DB and gRPC behavior.
|
|
if is_module_patched("socket"):
|
|
import psycogreen.gevent as pscycogreen_gevent
|
|
from grpc.experimental import gevent as grpc_gevent
|
|
|
|
grpc_gevent.init_gevent()
|
|
print("gRPC patched with gevent.", flush=True) # noqa: T201
|
|
pscycogreen_gevent.patch_psycopg()
|
|
print("psycopg2 patched with gevent.", flush=True) # noqa: T201
|
|
|
|
|
|
# Import after gevent patching.
|
|
from app import app, celery
|
|
|
|
__all__ = ["app", "celery"]
|