[Async-sig] Asynchronous cleanup is a problem

Yury Selivanov yselivanov at gmail.com
Wed Jul 6 21:17:48 EDT 2016


> ...does it actually work to re-enter a main loop from inside a __del__
> callback? It seems like you could get into really nasty states with
> multiple nested __del__ calls, or if a single sweep detects multiple
> pieces of garbage with __del__ methods, then some of those __del__
> calls could be delayed indefinitely while the first __del__ runs. Is
> the cycle collector even re-entrant?

We can have a flag on the async gen object to make sure that we run the finalizer only once. The finalizer will likely schedule async_gen.aclose() coroutine which will ensure a strong ref to the gen until it is closed. This can actually work.. ;)

Yury


More information about the Async-sig mailing list