[Python-Dev] What is the precise problem? [was: Reference cycles in Exception.__traceback__]

Victor Stinner victor.stinner at gmail.com
Sat Mar 8 14:01:50 CET 2014


2014-03-08 12:45 GMT+01:00 Antoine Pitrou <solipsis at pitrou.net>:
>> 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.
>
> So clearly the coroutine must be kept alive by something.

It's a reference cycle. Something like that:

Future -> Exception -> Traceback -> Frames -> Local variables ->
{Future, MyObject}

Victor


More information about the Python-Dev mailing list