diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index bfe82fa3d8c10d..fc654883e01ca9 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -644,14 +644,14 @@ def __sleep0(): async def sleep(delay, result=None): """Coroutine that completes after a given time (in seconds).""" - # check delay value is not nan - if math.isnan(delay): - raise ValueError("Invalid delay: NaN (not a number)") - if delay <= 0: await __sleep0() return result + # check delay value is not nan + if math.isnan(delay): + raise ValueError("Invalid delay: NaN (not a number)") + loop = events.get_running_loop() future = loop.create_future() h = loop.call_later(delay,