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 8:19 PM, Yury Selivanov <rep...@bugs.python.org>
wrote:

>
> 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 outline of the new unittest:
>
> 1. we have a queue with three queue.get() coroutines waiting for its
> items: `g1`, `g2`, `g3`
>
> 2. we do `push_nowait(i1)` and `push_nowait(i2)`; we cancel `g1`
>
> 3. the loop gets the chance to run
>
> 4. `g1` detects that it was cancelled and pushes the item `i1` in front of
> the queue (otherwise we just lose it).
>
> Now, the problem is that `g2` has already received `i2` (by
> `push_nowait`); and `i1` will end up consumed by `g3`!
>
> This all means that with getter coroutines being cancelled, it's possible
> that getters might receive queue items out of order.
>
> So the question is: is this a matter of documenting this behaviour, or we
> should consider some other design for queues implementation?
>
> ----------
>
> _______________________________________
> Python tracker <rep...@bugs.python.org>
> <http://bugs.python.org/issue23812>
> _______________________________________
>

----------

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

Reply via email to