Message206672
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. |
|
Date |
User |
Action |
Args |
2013-12-20 09:55:04 | vstinner | set | recipients:
+ vstinner, gvanrossum, pitrou |
2013-12-20 09:55:03 | vstinner | set | messageid: <1387533303.95.0.0629214738994.issue20032@psf.upfronthosting.co.za> |
2013-12-20 09:55:03 | vstinner | link | issue20032 messages |
2013-12-20 09:55:02 | vstinner | create | |
|