Skip to content

Commit

Permalink
pythongh-105331: Move check delay is nan section after delay <= 0 sec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
weijay0804 committed Jun 12, 2023
1 parent 4a08061 commit 11b9d7e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Lib/asyncio/tasks.py
Expand Up @@ -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,
Expand Down

0 comments on commit 11b9d7e

Please sign in to comment.