Repository navigation
Open
Description
Release target
Remove gevent and import-time monkey patching in SDK 0.12.0.
The release plan was updated on 2026-11-02: SDK 0.11.0 (#413) retains the existing runtime.
Coordinate this work with the native synchronous HTTPX2 migration in #414 / #415 for the same SDK 0.12.0 release.
Current state
- SDK main declares
gevent>=26.9.0and appliesmonkey.patch_all(sys=True)throughsrc/dify_plugin/_gevent.pyat package import. - Stdio uses
gevent.os.tp_read; TCP uses gevent socket/select/sleep; serverless includes a gevent WSGI path. - Model token estimation detects patched sockets and uses
gevent.threadpool.ThreadPool. IOServerdispatches synchronous plugin work throughThreadPoolExecutor(max_workers=MAX_WORKER), which is currently affected by global patching.- refactor(http)!: adopt native synchronous HTTPX2 for SDK 0.12 #415 moves SDK-owned HTTP calls to native synchronous HTTPX2 while retaining gevent in its current candidate.
Target for v0.12.0
- Remove
geventandgreenletfrom SDK runtime dependencies and lock data. - Remove package import-time monkey patching entirely.
- Keep synchronous plugin execution on native
ThreadPoolExecutorand document its worker behavior. - Use the shared synchronous HTTPX2 transport from refactor(http)!: adopt native synchronous HTTPX2 in v0.12.0 #414 / refactor(http)!: adopt native synchronous HTTPX2 for SDK 0.12 #415 for SDK HTTP requests, streaming, uploads, downloads, and serverless callbacks.
- Preserve local stdio, remote TCP, and serverless HTTP streaming behavior.
- Keep runtime boundaries explicit so future concurrency work can be implemented without global monkey patching.
The earlier urllib.request helper proposal is superseded by the selected HTTPX2 migration.
tiktoken may retain Requests/urllib3 as transitive dependencies for its own resource downloads.
Implementation work
- Delete the gevent import-side-effect module and its package-level import.
- Rewrite stdio reading around standard library primitives.
- Use native sockets and
selectorsorselectfor TCP, preserving timeout, reconnect, write serialization, and shutdown behavior. - Replace the serverless gevent WSGI branch with a supported server path using the native runtime.
- Replace gevent token-estimation isolation with direct execution or the existing native thread pool as justified by blocking behavior.
- Verify the HTTPX2 network backend, streaming ownership, timeouts, proxies, TLS, and cleanup with unpatched sockets.
- Update worker configuration, runtime documentation, and affected examples.
- Update the test entrypoint, coverage configuration, fixtures, and integration tests that currently assume gevent or patched threads.
Acceptance criteria
- Runtime code and package metadata have no gevent/greenlet references, and the resolved dependencies no longer include them.
- Package import leaves standard-library sockets, threads, and other modules unpatched.
- SDK-owned HTTP calls use synchronous HTTPX2, with the proxy/TLS/streaming regressions from refactor(http)!: adopt native synchronous HTTPX2 for SDK 0.12 #415 passing under the native runtime.
- Local stdio, remote TCP, and serverless smoke tests pass, including concurrent requests, reconnects, interruption, and shutdown.
-
just check, Python 3.12/3.13 tests and coverage gates, andjust buildpass for the combined SDK 0.12.0 candidate. - The SDK 0.12.0 release notes document the runtime and HTTP integration changes.
Activity
[-]refactor!: remove gevent runtime dependency in v0.10.0[/-][+]refactor!: remove gevent runtime dependency in v0.11.0[/+][-]refactor!: remove gevent runtime dependency in v0.11.0[/-][+]refactor(runtime)!: remove gevent runtime dependency in v0.12.0[/+]