Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2a961d3

Browse filesBrowse files
committed
Add NEWS and docs for eager task factory
1 parent 71eeda4 commit 2a961d3
Copy full SHA for 2a961d3

File tree

Expand file treeCollapse file tree

2 files changed

+28
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+28
-0
lines changed

‎Doc/library/asyncio-task.rst

Copy file name to clipboardExpand all lines: Doc/library/asyncio-task.rst
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,30 @@ Running Tasks Concurrently
518518
and there is no running event loop.
519519

520520

521+
Eager Task Factory
522+
==================
523+
524+
.. function:: eager_task_factory(loop, coro, *, name=None, context=None)
525+
526+
A task factory for eager task execution.
527+
528+
When using this factory (via ``loop.set_task_factory(asyncio.eager_task_factory)``),
529+
coroutines that are able to complete synchronously (without suspending)
530+
are returned immediately as a completed :class:`Future`.
531+
532+
A regular :class:`Task` is returned otherwise, at the first suspension of *coro*.
533+
534+
.. versionadded:: 3.12
535+
536+
.. function:: create_eager_task_factory(custom_task_constructor)
537+
538+
Create an eager task factory, similar to :ref:`eager_task_factory`,
539+
using the provided *eager_task_factory* when creating a new task instead
540+
of the default :class:`Task`.
541+
542+
.. versionadded:: 3.12
543+
544+
521545
Shielding From Cancellation
522546
===========================
523547

+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Implemented an eager task factory in asyncio. When set as a task factory on
2+
an event loop, it performs eager execution of coroutines and returns a
3+
completed future instead of scheduling a task to the event loop if the
4+
coroutine can complete without suspending.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.