I forgot the script to reproduce the bug. I attached it to this email
and to the issue: tb_bug.py.

Victor

2014-02-27 19:02 GMT+01:00 Victor Stinner <[email protected]>:
> Hi,
>
> I found some bugs with _TracebackLogger when loop.run_until_complete() is 
> used:
> http://code.google.com/p/tulip/issues/detail?id=155
>
> Try attached script to reproduce the issue with Tulip and Python 3.3.
> You should get:
> ---
> deque([Handle(<bound method _TracebackLogger.activate of...>, ())])
> ...
>     [<asyncio.futures._TracebackLogger object at 0x7facadefb3f8>]
>
> ---
>
> The activate() method of the _TracebackLogger is never executed, the
> _TracebackLogger is part of a reference cycle and cannot be collected
> by the garbage collector, and the unhandled exception is not logged.
>
> If you uncommend "fut = None" in task(), you get:
> ---
> deque([Handle(<bound method _TracebackLogger.activate of
> <asyncio.futures._TracebackLogger object at 0x7f9a98f8b3f8>>, ())])
> ---
>
> The _TracebackLogger is collected, but the unhandled exception is
> still not logged.
>
> In Python 3.4, it's better thanks to the PEP 442:
> http://legacy.python.org/dev/peps/pep-0442/
>
> In Python 3.3, the problem is that _TracebackLogger contains an
> exception which contains a traceback.
>
> For Trollius, it's also different because exception has no
> __traceback__ attribute, and so the formatting of the traceback cannot
> be deferred.
>
> So well, please take a look at my issue:
> http://code.google.com/p/tulip/issues/detail?id=155
>
> Victor
import asyncio
import gc
import logging

@asyncio.coroutine
def task(loop, fut):
    yield None
    try:
        raise RuntimeError()
    except Exception as exc:
        loop.call_soon(fut.set_exception, exc)
    fut = None
    loop = None

gc.set_debug(gc.DEBUG_UNCOLLECTABLE)
logging.basicConfig()

loop = asyncio.get_event_loop()
#loop.set_debug(True)
fut = asyncio.Future(loop=loop)
loop.run_until_complete(task(loop, fut))
print(loop._ready)

fut = None
loop.close()

Reply via email to