-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
[3.13] gh-133745: Fix asyncio task factory name/context kwarg breaks #133948
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
Changes from 13 commits
5c3c953
6247a57
ddfbeb2
9dcf0e8
d607230
f9786ce
36e8f04
ac5759a
363d336
2fd6255
2ba0d19
2e7556d
d3021ae
b26c1ff
8088dac
5c26ed7
d600dd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,7 +355,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, **kwargs) | ||
|
||
Schedule the execution of :ref:`coroutine <coroutine>` *coro*. | ||
Return a :class:`Task` object. | ||
|
@@ -364,19 +364,40 @@ Creating Futures and Tasks | |
for interoperability. In this case, the result type is a subclass | ||
of :class:`Task`. | ||
|
||
The arguments shown above are merely the most common ones, described below | ||
graingert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
The full function signature is largely the same as that of the | ||
:class:`Task` constructor (or factory) - all of the keyword arguments to | ||
this function are passed through to that interface, except *name*, | ||
or *context* if it is ``None``. | ||
|
||
If the *name* argument is provided and not ``None``, it is set as | ||
the name of the task using :meth:`Task.set_name`. | ||
|
||
An optional keyword-only *context* argument allows specifying a | ||
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 eagerly starting | ||
the execution of the :class:`asyncio.Task` at task creation time. | ||
If set to ``True`` and the event loop is running, the task will start | ||
executing the coroutine immediately, until the first time the coroutine | ||
blocks. If the coroutine returns or raises without blocking, the task | ||
will be finished eagerly and will skip scheduling to the event loop. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe we should document
graingert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.. versionchanged:: 3.8 | ||
Added the *name* parameter. | ||
|
||
.. versionchanged:: 3.11 | ||
Added the *context* parameter. | ||
|
||
.. versionchanged:: 3.13.3 | ||
Added ``kwargs`` which always passes on ``kwargs`` such as the *eager_start* | ||
parameter and *name* parameter. | ||
graingert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. versionchanged:: 3.13.4 | ||
Rolled back the change that passes on *name* and *context* (if it is None), | ||
passing on new keword arguments such as *eager_start* is still supported. | ||
graingert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. method:: loop.set_task_factory(factory) | ||
|
||
Set a task factory that will be used by | ||
|
@@ -388,6 +409,13 @@ Creating Futures and Tasks | |
event loop, and *coro* is a coroutine object. The callable | ||
must pass on all *kwargs*, and return a :class:`asyncio.Task`-compatible object. | ||
|
||
.. versionchanged:: 3.13.3 | ||
Required that all *kwargs* are passed on to :class:`asyncio.Task`. | ||
graingert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. versionchanged:: 3.13.4 | ||
*name* is no longer passed to task factories. *context* is no longer passed | ||
to task factories if it is ``None``. | ||
graingert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. method:: loop.get_task_factory() | ||
|
||
Return a task factory or ``None`` if the default one is in use. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
In 3.13.3 we accidentally changed the signature of the asyncio ``create_task()`` family of methods and how it calls a custom task factory in a backwards incompatible way. Since some 3rd party libraries have already made changes to work around the issue that might break if we simply reverted the changes, we're instead changing things to be backwards compatible with 3.13.2 while still supporting those workarounds for 3.13.3. In particular, the special-casing of ``name`` and ``context`` is back (until 3.14) and consequently eager tasks may still find that their name hasn't been set before they execute their first yielding await. | ||
kumaraditya303 marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.