Message326891
[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. |
|
Date |
User |
Action |
Args |
2018-10-02 17:59:06 | yselivanov | set | recipients:
+ yselivanov, vstinner, asvetlov, serhiy.storchaka, willingc, xtreak, fbidu |
2018-10-02 17:59:06 | yselivanov | set | messageid: <1538503146.6.0.545547206417.issue34728@psf.upfronthosting.co.za> |
2018-10-02 17:59:06 | yselivanov | link | issue34728 messages |
2018-10-02 17:59:06 | yselivanov | create | |
|