Skip to content

Commit 7297c01

Browse files
Dreamsorcererambv
authored andcommitted
Move get_running_loop()
1 parent 8ad4662 commit 7297c01

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Lib/asyncio/tasks.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,7 @@ def __sleep0():
635635

636636
async def sleep(delay, result=None, *, loop=None):
637637
"""Coroutine that completes after a given time (in seconds)."""
638-
if loop is None:
639-
loop = events.get_running_loop()
640-
else:
638+
if loop is not None:
641639
warnings.warn("The loop argument is deprecated since Python 3.8, "
642640
"and scheduled for removal in Python 3.10.",
643641
DeprecationWarning, stacklevel=2)
@@ -646,6 +644,9 @@ async def sleep(delay, result=None, *, loop=None):
646644
await __sleep0()
647645
return result
648646

647+
if loop is None:
648+
loop = events.get_running_loop()
649+
649650
future = loop.create_future()
650651
h = loop.call_later(delay,
651652
futures._set_result_unless_cancelled,

0 commit comments

Comments
 (0)