Message215647
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.) |
|
Date |
User |
Action |
Args |
2014-04-06 03:35:09 | gvanrossum | set | recipients:
+ gvanrossum, pitrou, vstinner, giampaolo.rodola, yselivanov, richard.kiss |
2014-04-06 03:35:09 | gvanrossum | set | messageid: <1396755309.02.0.635062663595.issue21163@psf.upfronthosting.co.za> |
2014-04-06 03:35:09 | gvanrossum | link | issue21163 messages |
2014-04-06 03:35:07 | gvanrossum | create | |
|