This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients gvanrossum, pitrou, vstinner
Date 2013-12-20.09:55:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1387533303.95.0.0629214738994.issue20032@psf.upfronthosting.co.za>
In-reply-to
Content
asyncio.Future.set_exception(exc) sets the exception attribute to exc, but exc.__traceback__ refers to frames and the current frame probably referes to the future instance.

Tell me if I'm wrong, but it looks like a reference cycle:
fut -- fut.exception --> exception --exception.__traceback__ -> traceback --traceback.tb_frame --> frame --frame.fb_locals --> fut

The frame class got a new clear() method in Python 3.4:
http://docs.python.org/dev/reference/datamodel.html#frame.clear

Maybe because of the PEP 442, the reference cycle is no more an issue. In fact, the following example calls fut destructor immediatly, at "fut = None" line.
---
import asyncio

fut = asyncio.Future()
try:
    raise ValueError()
except Exception as err:
    fut.set_exception(err)
fut = None
---

Attached patch breaks explicitly the reference cycle by scheduling a call to traceback.clear_frames() using call_soon(). The patch depends on asyncio_defer_format_tb.patch which is attached to the issue #19967.
History
Date User Action Args
2013-12-20 09:55:04vstinnersetrecipients: + vstinner, gvanrossum, pitrou
2013-12-20 09:55:03vstinnersetmessageid: <1387533303.95.0.0629214738994.issue20032@psf.upfronthosting.co.za>
2013-12-20 09:55:03vstinnerlinkissue20032 messages
2013-12-20 09:55:02vstinnercreate