You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Free-threaded builds: an idle worker thread keeps a sync route handler's last response #873
On a free-threaded build with the GIL off, an object created on one thread and dropped by another is freed only when the thread that created it next runs Python code. #870 handled this for Citry's own Events check threads by having an idle check thread wake once a second.
Route handlers that are plain functions have the same pattern. The ASGI adapter runs them through asyncio.to_thread (packages/py/citry/citry/util/routing.py, the function that calls route handlers), which uses the event loop's default thread pool. A handler builds its response, and often request data and rendered HTML, on a pool thread. The caller drops them, but if that pool thread then sits idle, waiting for the next job with no time limit, those objects stay in memory until the thread gets more work.
This is a delay, not a leak: a busy server keeps its pool threads running. A quiet server, or one with a large pool, can hold the last responses of each idle thread for a long time.
Activity