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.

Author yselivanov
Recipients asvetlov, fbidu, serhiy.storchaka, vstinner, willingc, xtreak, yselivanov
Date 2018-10-02.17:59:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1538503146.6.0.545547206417.issue34728@psf.upfronthosting.co.za>
In-reply-to
Content
[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.
History
Date User Action Args
2018-10-02 17:59:06yselivanovsetrecipients: + yselivanov, vstinner, asvetlov, serhiy.storchaka, willingc, xtreak, fbidu
2018-10-02 17:59:06yselivanovsetmessageid: <1538503146.6.0.545547206417.issue34728@psf.upfronthosting.co.za>
2018-10-02 17:59:06yselivanovlinkissue34728 messages
2018-10-02 17:59:06yselivanovcreate