diff --git a/newsfragments/3113.doc.rst b/newsfragments/3113.doc.rst new file mode 100644 index 0000000000..7ce407a29e --- /dev/null +++ b/newsfragments/3113.doc.rst @@ -0,0 +1 @@ +Document that :func:`trio.sleep_forever` is guaranteed to raise an exception now. diff --git a/src/trio/_timeouts.py b/src/trio/_timeouts.py index 417f1818fa..7ce123c7c5 100644 --- a/src/trio/_timeouts.py +++ b/src/trio/_timeouts.py @@ -61,7 +61,11 @@ def move_on_after( async def sleep_forever() -> NoReturn: """Pause execution of the current task forever (or until cancelled). - Equivalent to calling ``await sleep(math.inf)``. + Equivalent to calling ``await sleep(math.inf)``, except that if manually + rescheduled this will raise a `RuntimeError`. + + Raises: + RuntimeError: if rescheduled """ await trio.lowlevel.wait_task_rescheduled(lambda _: trio.lowlevel.Abort.SUCCEEDED)