Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Pushed Handlers Create Cyclic References with __del__() #46

drakeguan opened this Issue · 2 comments

2 participants


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


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.


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 vmalloc closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.