[issue21163] asyncio task possibly incorrectly garbage collected

2014-06-19 Thread STINNER Victor
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

[issue21163] asyncio task possibly incorrectly garbage collected

2014-06-06 Thread STINNER Victor
Changes by STINNER Victor : -- components: +Asyncio ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

[issue21163] asyncio task possibly incorrectly garbage collected

2014-04-05 Thread Guido van Rossum
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*

[issue21163] asyncio task possibly incorrectly garbage collected

2014-04-05 Thread Richard Kiss
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 littl

[issue21163] asyncio task possibly incorrectly garbage collected

2014-04-05 Thread Richard Kiss
Richard Kiss added the comment: I'll investigate further. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: ht

[issue21163] asyncio task possibly incorrectly garbage collected

2014-04-05 Thread Guido van Rossum
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

[issue21163] asyncio task possibly incorrectly garbage collected

2014-04-05 Thread Richard Kiss
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 . The BitcoinPeerProtocol class multiplexes protocol messages into multiple

[issue21163] asyncio task possibly incorrectly garbage collected

2014-04-05 Thread Guido van Rossum
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 reason

[issue21163] asyncio task possibly incorrectly garbage collected

2014-04-05 Thread Brett Cannon
Changes by Brett Cannon : -- nosy: +giampaolo.rodola, gvanrossum, haypo, pitrou, yselivanov ___ Python tracker ___ ___ Python-bugs-lis

[issue21163] asyncio task possibly incorrectly garbage collected

2014-04-05 Thread Richard Kiss
Changes by Richard Kiss : -- title: asyncio Task Possibly Incorrectly Garbage Collected -> asyncio task possibly incorrectly garbage collected ___ Python tracker ___ ___

[issue21163] asyncio Task Possibly Incorrectly Garbage Collected

2014-04-05 Thread Richard Kiss
Changes by Richard Kiss : -- hgrepos: -231 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python

[issue21163] asyncio Task Possibly Incorrectly Garbage Collected

2014-04-05 Thread Richard Kiss
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.