Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
minor tweaks
  • Loading branch information
kumaraditya303 committed Jun 12, 2023
commit 49c55c69a14375e4e90ee44933dad4b2bb220dd9
3 changes: 2 additions & 1 deletion Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ Sleeping
Removed the *loop* parameter.

.. versionchanged:: 3.13
If the *delay* value is nan will raise ValueError.
Raises :exc:`ValueError` if *delay* is :data:`math.nan`.


Running Tasks Concurrently
==========================
Expand Down
2 changes: 0 additions & 2 deletions Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,10 @@ def __sleep0():

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

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)")

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Raise :exc:`ValueError` if the `delay` argument to :func:`asyncio.sleep` is a NaN (matching :func:`time.sleep`).
Raise :exc:`ValueError` if the `delay` argument to :func:`asyncio.sleep` is a NaN (matching :func:`time.sleep`).