Guido van Rossum added the comment:

Thanks for understanding. 

It's definitely subtle: there is also some code in asyncio that logs an error 
when a Future holding an exception becomes unreachable before anyone has asked 
for it; this has been a valuable debugging tool, and it depends on *not* 
holding references to Futures.

Regarding the difference between Python 3.3 and 3.4, I don't know the exact 
reason, but GC definitely gets more precise with each new revision, and there 
are also some differences in how exactly the debug feature I just mentioned is 
implemented (look for _tb_logger in asyncio/futures.py).

OTOH it does seem a little odd to just GC a coroutine that hasn't exited yet, 
and I'm not 100% convinced there *isn't* a bug here. The more I think about it, 
the more I think that it's suspicious that it's always the *first* iteration 
that gets GC'ed. So I'd like to keep this open as a reminder.

Finally, I'm not sure the analogy with threads holds -- a thread manages OS 
resources that really do have to be destroyed explicitly, but that's not so for 
tasks, and any cleanup you do need can be handled using try/finally. (In 
general drawing analogies between threads and asyncio tasks/coroutines is 
probably one of the less fruitful lines of thinking about the latter; there are 
more differences than similarities.)

----------
resolution: invalid -> remind

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21163>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to