[issue34728] deprecate *loop* argument for asyncio.sleep

STINNER Victor report at bugs.python.org
Tue Oct 2 03:44:32 EDT 2018


STINNER Victor <vstinner at redhat.com> added the comment:

FYI if I recall correctly, in the past, we preferred to pass explicitly the loop to avoid to have to get the current loop which may add an overhead. But the current trend is to get rid of the explicit loop parameter.

> asyncio.sleep is a coroutine; passing a *loop* argument to it makes no sense anymore.

sleep() requires the current event loop:

    if loop is None:
        loop = events.get_running_loop()
    else:
        warnings.warn("The loop argument is deprecated and scheduled for "
                      "removal in Python 3.10.",
                      DeprecationWarning, stacklevel=2)

    future = loop.create_future()
    h = loop.call_later(delay,
                        futures._set_result_unless_cancelled,
                        future, result)

Why does it not make sense to pass the loop to sleep? "it makes no sense anymore" something changes?

I'm not against the change, I'm just trying to understand the rationale for other changes :-)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34728>
_______________________________________


More information about the Python-bugs-list mailing list