This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Asyncio Event.wait() is a hold over from before awaitable, and should be awaitable
Type: enhancement Stage: resolved
Components: asyncio Versions: Python 3.8
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, fried, hniksic, lukasz.langa, yselivanov
Priority: normal Keywords: patch

Created on 2018-05-16 16:57 by fried, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6916 closed fried, 2018-05-16 18:15
Messages (5)
msg316842 - (view) Author: Jason Fried (fried) * Date: 2018-05-16 16:57
wait is a very overloaded word in asyncio.  Events and Conditions are not consistent with the rest of asyncio.  

Why don't Future and Task have wait() methods? well because they are awaitable

Some subjective reasoning:
Every time I go to use one of these things, I attempt to await them like everything else in the Asyncio world and get a nice exception for it.

   await event

vs

   await event.wait()

I propose we make conditions and events awaitable and deprecate the .wait or at-least remove it from the documentation.
msg316847 - (view) Author: Jason Fried (fried) * Date: 2018-05-16 18:09
Removed Condition from this request, because it has an __await__ method for supporting the the deprecated pattern

  with async cond:

I'll open a different bug, for Condition behavior for 3.9 when we can remove the deprecated pattern.
msg316853 - (view) Author: Hrvoje Nikšić (hniksic) * Date: 2018-05-16 19:30
Deprecating Event.wait would be incorrect because Event was designed to mimic the threading.Event class which has a (blocking) wait() method[1].

Supporting `await event` is still worthwhile, though.

[1]
https://docs.python.org/2/library/threading.html#threading.Event.wait
msg316962 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-05-17 16:42
> Deprecating Event.wait would be incorrect because Event was designed to mimic the threading.Event class which has a (blocking) wait() method[1].

This is rather important. I'd like to continue maintaining this similarity. Adding 'await event' would be similar (in a way) to making instances of threading.Event callable.  So deprecation of '.wait()' isn't something we will do.

Having *both* 'await event.wait()' and 'await event' worries me.  IMO the slight readability improvement isn't worth the added complexity.
msg317113 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2018-05-19 11:19
-1 for the proposal
History
Date User Action Args
2022-04-11 14:59:00adminsetgithub: 77725
2018-05-21 09:31:38asvetlovsetstatus: open -> closed
resolution: rejected
stage: patch review -> resolved
2018-05-19 11:19:17asvetlovsetmessages: + msg317113
2018-05-17 16:42:48yselivanovsetmessages: + msg316962
2018-05-16 19:30:00hniksicsetnosy: + hniksic
messages: + msg316853
2018-05-16 18:15:50friedsetkeywords: + patch
stage: patch review
pull_requests: + pull_request6584
2018-05-16 18:09:03friedsetmessages: + msg316847
title: Asyncio Event.wait() and Condition.wait() is a hold over from before awaitable, and should be awaitable -> Asyncio Event.wait() is a hold over from before awaitable, and should be awaitable
2018-05-16 16:57:54friedcreate