[Async-sig] question re: asyncio.Condition lock acquisition order

Chris Jerdonek chris.jerdonek at gmail.com
Tue Jun 27 03:29:10 EDT 2017


I have a couple questions about asyncio's synchronization primitives.

Say a coroutine acquires an asyncio Condition's underlying lock, calls
notify() (or notify_all()), and then releases the lock. In terms of
which coroutines will acquire the lock next, is any preference given
between (1) coroutines waiting to acquire the underlying lock, and (2)
coroutines waiting on the Condition object itself? The documentation
doesn't seem to say anything about this.

Also, more generally (and I'm sure this question gets asked a lot),
does asyncio provide any guarantees about the order in which awaiting
coroutines are awakened? For example, for synchronization primitives,
does each primitive maintain a FIFO queue of who will be awakened
next, or are there no guarantees about the order?

Thanks a lot,
--Chris


More information about the Async-sig mailing list