Andrew Svetlov <andrew.svet...@gmail.com> added the comment:
Good point. Currently, asyncio lock objects don't provide a strong FIFO guarantee. In a tight loop, a task can re-acquire the lock just after releasing even if there are pending waiters that were scheduled earlier. It's true also for Lock, Conditional, Event, etc. The solution requires *async* release method. Since the change is not backward compatible, a new method should be added, e.g. `await sem.release_and_wait()` for endorsing the context switch if there are pending waiters. async context manager can be modified for using the new method without backward compatibility problems easily. A hero who can help is welcome! ---------- assignee: -> asvetlov title: asyncio.Semaphore waiters deque doesn't work -> asyncio.Semaphore waiters deqeueu doesn't work type: behavior -> _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45997> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com