gh-128307: Support eager_start=<bool> in create_eager_task_factory and various create_task functions (#128306)

Some create_task() functions were changed from `name=None, context=None` to `**kwargs`.

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
This commit is contained in:
Thomas Grainger 2025-05-05 05:58:07 +01:00 committed by GitHub
parent c4cc5d58ae
commit 08d7687094
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 85 additions and 19 deletions

View file

@ -361,7 +361,7 @@ Creating Futures and Tasks
.. versionadded:: 3.5.2
.. method:: loop.create_task(coro, *, name=None, context=None)
.. method:: loop.create_task(coro, *, name=None, context=None, eager_start=None)
Schedule the execution of :ref:`coroutine <coroutine>` *coro*.
Return a :class:`Task` object.
@ -377,12 +377,20 @@ Creating Futures and Tasks
custom :class:`contextvars.Context` for the *coro* to run in.
The current context copy is created when no *context* is provided.
An optional keyword-only *eager_start* argument allows specifying
if the task should execute eagerly during the call to create_task,
or be scheduled later. If *eager_start* is not passed the mode set
by :meth:`loop.set_task_factory` will be used.
.. versionchanged:: 3.8
Added the *name* parameter.
.. versionchanged:: 3.11
Added the *context* parameter.
.. versionchanged:: next
Added the *eager_start* parameter.
.. method:: loop.set_task_factory(factory)
Set a task factory that will be used by