Skip to content

Commit 893bb26

Browse files
kovanclaude
andcommitted
gh-142044: Add note to prefer asyncio.timeout/timeout_at over Timeout
Document that users should prefer using asyncio.timeout() or asyncio.timeout_at() rather than directly instantiating the Timeout class, matching the guidance already present in the source code. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7e2c9bd commit 893bb26

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Doc/library/asyncio-task.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,11 @@ Timeouts
771771
An :ref:`asynchronous context manager <async-context-managers>`
772772
for cancelling overdue coroutines.
773773

774+
.. note::
775+
776+
Prefer using :func:`asyncio.timeout` or :func:`asyncio.timeout_at`
777+
rather than instantiating :class:`Timeout` directly.
778+
774779
``when`` should be an absolute time at which the context should time out,
775780
as measured by the event loop's clock:
776781

0 commit comments

Comments
 (0)