STINNER Victor added the comment:
Ok, I agree that this issue is very tricky :-)
The first problem in asyncio-gc-issue.py is that the producer keeps *weak*
references to Queue object, so the Queue objects are quickly destroyed,
especially if gc.collect() is called explicitly.
When yield from
Changes by STINNER Victor victor.stin...@gmail.com:
--
components: +Asyncio
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21163
___
___
New submission from Richard Kiss:
Some tasks created via asyncio are vanishing because there is no reference to
their resultant futures.
This behaviour does not occur in Python 3.3.3 with asyncio-0.4.1.
Also, doing a gc.collect() immediately after creating the tasks seems to fix
the problem.
Changes by Richard Kiss h...@richardkiss.com:
--
hgrepos: -231
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21163
___
___
Python-bugs-list
Changes by Richard Kiss h...@richardkiss.com:
--
title: asyncio Task Possibly Incorrectly Garbage Collected - asyncio task
possibly incorrectly garbage collected
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21163
Changes by Brett Cannon br...@python.org:
--
nosy: +giampaolo.rodola, gvanrossum, haypo, pitrou, yselivanov
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21163
___
Guido van Rossum added the comment:
Ouch. That example is very obfuscated -- I fail to understand what it is trying
to accomplish. Running it I see that it always prints 100 for the count with
3.3 or DO_CG on; for me it prints 87 with 3.4 an DO_GC off. But I wouldn't be
surprised if the
Richard Kiss added the comment:
I agree it's confusing and I apologize for that.
Background:
This multiplexing pattern is used in pycoinnet, a bitcoin client I'm developing
at https://github.com/richardkiss/pycoinnet. The BitcoinPeerProtocol class
multiplexes protocol messages into multiple
Guido van Rossum added the comment:
Most likely your program is simply relying on undefined behavior and the right
way to fix it is to keep strong references to all tasks until they
self-destruct.
--
___
Python tracker rep...@bugs.python.org
Richard Kiss added the comment:
I'll investigate further.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21163
___
___
Python-bugs-list mailing
Richard Kiss added the comment:
You were right: adding a strong reference to each Task seems to have solved the
original problem in pycoinnet. I see that the reference to the global lists of
asyncio.tasks is a weakset, so it's necessary to keep a strong reference myself.
This does seem a
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*
12 matches
Mail list logo