Skip to content

Document that trio.sleep_forever will raise RuntimeError instead of returning #3115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions newsfragments/3113.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document that :func:`trio.sleep_forever` is guaranteed to raise an exception now.
6 changes: 5 additions & 1 deletion src/trio/_timeouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading