[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-07 Thread Guido van Rossum
Guido van Rossum added the comment: So this looks like it will miss 3.5.0rc1. How confident are we that the new patch won't introduce new bugs? This late in the release process that would be awkward. On Fri, Aug 7, 2015 at 12:47 AM, Gustavo J. A. M. Carneiro rep...@bugs.python.org wrote:

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-07 Thread Yury Selivanov
Yury Selivanov added the comment: Yep, GH works. Thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23812 ___ ___ Python-bugs-list mailing

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-07 Thread Yury Selivanov
Yury Selivanov added the comment: Guido, I agree, let's not push the updated implementation in 3.5.0. Gustavo, could you please generate the patch with hg diff, so that code review here works? And I think we need a new issue to track the new patch. -- nosy: +larry priority: deferred

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-07 Thread Yury Selivanov
Changes by Yury Selivanov yseliva...@gmail.com: -- nosy: -larry priority: release blocker - deferred blocker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23812 ___

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-07 Thread Gustavo J. A. M. Carneiro
Gustavo J. A. M. Carneiro added the comment: I am not using hg anymore, since asyncio migrated to git. Here's a github PR, does that help? https://github.com/python/asyncio/pull/260 -- ___ Python tracker rep...@bugs.python.org

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-07 Thread Gustavo J. A. M. Carneiro
Gustavo J. A. M. Carneiro added the comment: I was wrong, there still needs to be some cleanup in cancellation, even with the new approach. But it does solve the out-of-order problem. I don't know if it should be applied to rc1. I wish I had more time to test. Up to you guys. --

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-06 Thread Gustavo J. A. M. Carneiro
Gustavo J. A. M. Carneiro added the comment: I don't think the order for multiple concurrent getters matters that much. With analogy with the threading case, if multiple threads are blocked get()ing an item from the same queue, I would not presume to expect anything about the ordering which

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-06 Thread Guido van Rossum
Guido van Rossum added the comment: Honestly, I've lost track of the queue design. Maybe the push-back on cancellation is just wrong? After all, if a coroutine has received an item, it's out of the queue, even if it gets cancelled before it can do anything with the item. On Thu, Aug 6, 2015 at

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-06 Thread Guido van Rossum
Guido van Rossum added the comment: Honestly, I've lost track of the queue design. Maybe the push-back on cancellation is just wrong? After all, if a coroutine has received an item, it's out of the queue, even if it gets cancelled before it can do anything with the item. --

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-06 Thread Yury Selivanov
Yury Selivanov added the comment: Honestly, I've lost track of the queue design. Maybe the push-back on cancellation is just wrong? After all, if a coroutine has received an item, it's out of the queue, even if it gets cancelled before it can do anything with the item. I think the

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-06 Thread Yury Selivanov
Yury Selivanov added the comment: A better design is to make it so the future that get() is waiting for doesn't actually receive the item, it is only used to wake up the get() coroutine. I would be something like: 1. get(): in case the queue is empty, create a Future, add it to _getters,

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-06 Thread Gustavo J. A. M. Carneiro
Gustavo J. A. M. Carneiro added the comment: Sure, just give me a couple of days. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23812 ___ ___

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-06 Thread Roundup Robot
Roundup Robot added the comment: New changeset 024d4f4011c9 by Yury Selivanov in branch '3.4': Issue #23812: Fix getter-cancellation with many pending getters code path https://hg.python.org/cpython/rev/024d4f4011c9 New changeset 2752fe734bfb by Yury Selivanov in branch '3.5': Merge 3.4 (issue

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-06 Thread Yury Selivanov
Yury Selivanov added the comment: Guido, Victor, I've just pushed a commit to fix a misspelled method call in queues.py (related to the previous commit in this issue). Along with fixing the bug and writing a unittest for it, I discovered an issue with the current queues design. Here's an

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-05 Thread Roundup Robot
Roundup Robot added the comment: New changeset 7aa2d3e1c885 by Yury Selivanov in branch '3.4': Issue #23812: Fix asyncio.Queue.get() to avoid loosing items on cancellation. https://hg.python.org/cpython/rev/7aa2d3e1c885 New changeset d5644d7e222d by Yury Selivanov in branch '3.5': Issue #23812:

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-08-05 Thread Yury Selivanov
Yury Selivanov added the comment: The fix is committed. Closing the issue. Thanks a lot, Gustavo! -- resolution: - fixed stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23812

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-07-15 Thread Gustavo J. A. M. Carneiro
Gustavo J. A. M. Carneiro added the comment: Don't know if it helps, but I made a github pull request for this: https://github.com/python/asyncio/pull/256 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23812

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-05-14 Thread Yury Selivanov
Changes by Yury Selivanov yseliva...@gmail.com: -- priority: normal - deferred blocker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23812 ___ ___

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-04-03 Thread STINNER Victor
STINNER Victor added the comment: queue_bug.py: script to reproduce the bug. I confirm that Queue.get() sometimes looses items when it is cancelled. The waiter contains the result, but the waiter is lost when get() is cancelled. Queue.get() waiter got a result, but Queue.get() wakeup is only

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-03-31 Thread Gustavo J. A. M. Carneiro
Gustavo J. A. M. Carneiro added the comment: So I uploaded a new patch version fixing a similar problem in put(). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23812 ___

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-03-31 Thread Guido van Rossum
Guido van Rossum added the comment: I'm sorry, I don't have time to review this (and it's subtle enough that I don't want to approve it without understanding). Maybe Victor understands? -- ___ Python tracker rep...@bugs.python.org

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-03-30 Thread Gustavo J. A. M. Carneiro
Changes by Gustavo J. A. M. Carneiro gjcarne...@gmail.com: Added file: http://bugs.python.org/file38741/Issue23812.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23812 ___

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-03-30 Thread Gustavo J. A. M. Carneiro
New submission from Gustavo J. A. M. Carneiro: I have a pattern where I read from a queue with a timeout, generally like this: while True: reader = asyncio.async(wait_for(queue.get(), 0.1)) try: item = (yield from reader) except asyncio.TimeoutError: reader.cancel() continue

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-03-30 Thread Gustavo J. A. M. Carneiro
Gustavo J. A. M. Carneiro added the comment: - Are there other places where a cancellation can have a similar effect? Maybe the same logic in put()? Hm.. I didn't look, but yes, it does look like it might be affected by the same issue. I'll try to create a test for that to confirm. how

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-03-30 Thread Guido van Rossum
Guido van Rossum added the comment: Make sense. I'll be waiting for your updated patch. Thanks for both the bug report and the fix! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23812

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-03-30 Thread Gustavo J. A. M. Carneiro
Gustavo J. A. M. Carneiro added the comment: I created a codereview issue: https://codereview.appspot.com/222930043 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23812 ___

[issue23812] asyncio.Queue.put_nowait(), followed get() task cancellation leads to item being lost

2015-03-30 Thread Guido van Rossum
Guido van Rossum added the comment: Looks like a valid bug report, I like the test you provided, and the fix seems on the right track. Comments on the fix: - I'd really like to see a rietveld diff for both patches. - Are there other places where a cancellation can have a similar effect? Maybe