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
SentryAsgiMiddleware keeps its application alive until cyclic garbage collection #8351
The application reference is released as soon as the last reference to the wrapper is dropped.
Actual result
On CPython the first print is True and the second is False. The wrapper stores a bound method in its __call__ slot, and that method references the wrapper. The Starlette integration constructs a wrapper on each ASGI invocation, so the wrapper and its application closure accumulate until cyclic garbage collection.
Would you be open to binding the ASGI2 or ASGI3 method when __call__ is accessed? That would keep the original synchronous and asynchronous callable behavior, including the coroutine inspection used for ASGI version detection. I can include a regression test that completes a request in both modes and checks that the wrapper releases the application before collection.
Activity
linear-code commentedon Nov 23, 2026
PY-3093