Re: [Python-Dev] What is the precise problem? [was: Reference cycles in Exception.__traceback__]
2014-03-08 1:14 GMT+01:00 Jim Jewett
Could you clarify what the problem actually is?
Please see: http://bugs.python.org/file33238/never_deleted.py
I would not expect it to be cleared at least until go runs ... and reading the ticket, it sounds like it is cleared then.
Attached script: never_deleted2.py, it's almost the same but it
explains better the problem. The script creates MyObject and Future
objects which are never deleted. Calling gc.collect() does *not* break
the reference cycle (between the future, the exception, traceback and
frames). Stopping the event loop does not remove Future nor MyObject
objects. Only exiting Python does remove the Future object.
The Future destructor calls code between this code fails between
Python is exiting and so most symbols are set to None. I'm testing
with Python 3.4 default, so with Antoine's PEP 442 and Serhiy's
changes on Python shutdown (restore builtins at exit).
The Future destructor is used in asyncio to notice the developer that
the application has a bug, the exception was not handled which may be
a major bug.
And MyObject is not destroyed which is an obvious memory leak, beause
there is no more explicit reference to it.
Script output:
---
gc.collect
stop!
exit
--- Logging error ---
Traceback (most recent call last):
--- Logging error ---
Traceback (most recent call last):
Exception ignored in:
participants (8)
-
Antoine Pitrou
-
Chris Angelico
-
Guido van Rossum
-
Jim J. Jewett
-
Maciej Fijalkowski
-
Mark Shannon
-
Nick Coghlan
-
Victor Stinner