Hi,
I am observing daphne hanging in a production deployment using an older version of asgiref. In debugging it, I also looked at asgiref and suggest there being a bug (which may be different from the one causing my hang).
AsyncSingleThreadContext.aexit is an asynchronous function and therefore should not be calling any blocking code. As it happens, the executor variable happens to become an instance of ThreadPoolExecutor and its shutdown method happens to have a wait parameter defaulting to True. Therefore executor.shutdown() theoretically may block.
Indeed, that is exactly what I am observing by hooking up austin at daphne. The root cause may be something else and #492 is a plausible root cause for what I see. And while that change may make the problem at hand unobservable, the fact that blocking code is called from async context looks like a separate bug to me.