classification
Title: asyncio.Condition should become awaitable in 3.9
Type: Stage: resolved
Components: asyncio Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, fried, lukasz.langa, yselivanov
Priority: normal Keywords:

Created on 2018-05-16 18:25 by fried, last changed 2018-05-21 09:29 by asvetlov. This issue is now closed.

Messages (2)
msg316848 - (view) Author: Jason Fried (fried) * Date: 2018-05-16 18:25
In 3.9 we can remove the deprecated pattern for accepting __enter__ and __exit__ for locks.  This will free up __await__ for Condition to use for replacing .wait() which is wart from before awaitables. 

My new proposed behavior is

await cond 

which would be equivalent of:

async with cond:
    await cond.wait()
msg317223 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2018-05-21 09:29
No, condition variables don't work this way.
The proper code looks like:

async with cond:
    while not <condition met>:
        await cond.wait()
    <do work when the condition is satisfied>

It cannot be collapsed to just `await cond`.
History
Date User Action Args
2018-05-21 09:29:32asvetlovsetstatus: open -> closed
resolution: rejected
messages: + msg317223

stage: resolved
2018-05-16 18:25:47friedcreate