Skip to content

Commit

Permalink
pythongh-105331: Fix asyncio.sleep() bug
Browse files Browse the repository at this point in the history
  • Loading branch information
weijay0804 committed Jun 11, 2023
1 parent 3a314f7 commit f2008da
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Lib/asyncio/tasks.py
Expand Up @@ -642,6 +642,12 @@ def __sleep0():

async def sleep(delay, result=None):
"""Coroutine that completes after a given time (in seconds)."""

# check delay value is not nan
import math
if math.isnan(delay):
raise ValueError("Invalid value NaN (not a number)")

if delay <= 0:
await __sleep0()
return result
Expand Down

0 comments on commit f2008da

Please sign in to comment.