[issue20032] asyncio.Future.set_exception() creates a reference cycle

Guido van Rossum report at bugs.python.org
Fri Dec 20 23:23:30 CET 2013


Guido van Rossum added the comment:

The cycle will be cleaned up (and the message printed) when the
garbage collector runs next. Your demo doesn't do anything else, so it
never allocates memory, so it never runs gc.collect(). But that's only
because it's a toy program.

Maybe it's time to look into
http://code.google.com/p/tulip/issues/detail?id=42 ? (It proposes to
run gc.collect() occasionally when the loop is idle.)

I am also concerned about Antoine's point -- the patch may actually
*prolong* the life of the traceback.

On Fri, Dec 20, 2013 at 2:15 PM, STINNER Victor <report at bugs.python.org> wrote:
>
> STINNER Victor added the comment:
>
>> Do you have an example of code that behaves differently with this patch?  I can't find any.
>
> I didn't check in the Python standard library, but the reference cycle is obvious, and I hate such issue. It introduces tricky issues like memory leaks.
>
> Here is an example to demonstrate the issue. The "DELETE OBJECT" message is never displayed, so the object is never deleted (memory leak).
>
> Comment "fut.set_exception(err)" line to delete the object, or apply attached patch.
>
> ----------
> Added file: http://bugs.python.org/file33238/never_deleted.py
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue20032>
> _______________________________________

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20032>
_______________________________________


More information about the Python-bugs-list mailing list