Skip to content

Commit 3d592af

Browse files
authored
Document that trio.sleep_forever will raise RuntimeError instead of returning (#3115)
* Document RuntimeError * Emphasize that it never returns
1 parent c47758c commit 3d592af

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

newsfragments/3113.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Document that :func:`trio.sleep_forever` is guaranteed to raise an exception now.

src/trio/_timeouts.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ def move_on_after(
6161
async def sleep_forever() -> NoReturn:
6262
"""Pause execution of the current task forever (or until cancelled).
6363
64-
Equivalent to calling ``await sleep(math.inf)``.
64+
Equivalent to calling ``await sleep(math.inf)``, except that if manually
65+
rescheduled this will raise a `RuntimeError`.
66+
67+
Raises:
68+
RuntimeError: if rescheduled
6569
6670
"""
6771
await trio.lowlevel.wait_task_rescheduled(lambda _: trio.lowlevel.Abort.SUCCEEDED)

0 commit comments

Comments
 (0)