Pushed Handlers Create Cyclic References with __del__() #46

drakeguan opened this Issue Nov 28, 2011 · 2 comments


None yet
2 participants

This prevents handlers from being closeed on exit if pop_application is not called.


vmalloc commented May 28, 2013

Yes. The handler is not popped from the stack in this example, meaning there's a cyclic reference with a del in it.

Solving this is tricky -- but you can easily work around this by using with instead of push_application():

with h1:

This will cause h1 to be popped right before the exception propagation, causing it to be properly collected.


vmalloc commented Aug 10, 2013

Going to leave this as unfixed for now. Python 3.4 is about to land with a proper fix for this issue in Python itself (properly handling cycles with destructors). If the workaround is not good enough for this issue feel free to comment or reopen so that we can discuss it further.

vmalloc closed this Aug 10, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment