sys.exc_info() called from publish returns a tuple containing the exception's traceback object, which has a reference to the
publish frame. Storing that in a local variable creates a reference cycle. Clear that variable in a finally block to avoid this.
I don't have a test for this, nor much of an idea of how to write one. I noticed it while auditing an application for reference cycle problems of this kind after finding that it had severe memory leaks on Python 3; this probably doesn't contribute much to that, but it seems worth fixing anyway.
sys.exc_info()
called frompublish
returns a tuple containing the exception's traceback object, which has a reference to thepublish
frame. Storing that in a local variable creates a reference cycle. Clear that variable in afinally
block to avoid this.I don't have a test for this, nor much of an idea of how to write one. I noticed it while auditing an application for reference cycle problems of this kind after finding that it had severe memory leaks on Python 3; this probably doesn't contribute much to that, but it seems worth fixing anyway.