[issue34728] deprecate *loop* argument for asyncio.sleep
Yury Selivanov
report at bugs.python.org
Tue Oct 2 13:59:06 EDT 2018
Yury Selivanov <yselivanov at gmail.com> added the comment:
[victor]
> Why does it not make sense to pass the loop to sleep? "it makes no sense anymore" something changes?
[andrew]
`loop` argument passed to sleep should be always the same as returned from `get_running_loop()`.
What Andrew said.
Basically, it wasn't *ever* possible to pass a loop to sleep() that would be different from the loop that would run it, because sleep() is a *coroutine*.
In asyncio some APIs are functions and some are coroutines.
* asyncio.gather(), for example, is a function. You can call it from top-level code (and pass an event loop to it) or from a coroutine.
* asyncio.sleep(), wait(), and wait_for() are *coroutines*; they can only be called from other coroutines or if you wrap them into a Task; in all cases, *loop* is always 100% defined for them.
Passing the loop isn't even a viable micro-optimization, it's just pointless. This extra argument just adds to the confusion and promotes bad patterns, so we want to eventually remove it.
----------
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34728>
_______________________________________
More information about the Python-bugs-list
mailing list