| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -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. | ||
| Expand All | @@ -364,19 +364,38 @@ Creating Futures and Tasks | |
| for interoperability. In this case, the result type is a subclass | ||
| of :class:`Task`. | ||
|
|
||
| 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. | ||
|
|
||
|
Comment thread
Outdated
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI don't believe we should document eager_start here at all. I doesn't require special treatment, it can just be put in **kwargs. It looks like we added this in 3.13.4, and such feature changes in a bugfix release are frowned upon. We should only advertise **kwargs as an unfortunate added in3.13.3 and fixed in 3.13.4.
Sorry, something went wrong.
All reactions
Comment thread
graingert marked this conversation as resolved.
Resolved
|
||
| .. versionchanged:: 3.8 | ||
| Added the *name* parameter. | ||
|
|
||
| .. versionchanged:: 3.11 | ||
| Added the *context* parameter. | ||
|
|
||
| .. versionchanged:: 3.13.3 | ||
| Added ``kwargs`` which passes on arbitrary extra parameters, including ``name`` and ``context``. | ||
|
|
||
| .. versionchanged:: 3.13.4 | ||
| Rolled back the change that passes on *name* and *context* (if it is None), | ||
| while still passing on other arbitrary keyword arguments (to avoid breaking backwards compatibility with 3.13.3). | ||
|
|
||
| .. method:: loop.set_task_factory(factory) | ||
|
|
||
| Set a task factory that will be used by | ||
| Expand All | @@ -388,6 +407,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`. | ||
|
|
||
| .. versionchanged:: 3.13.4 | ||
| *name* is no longer passed to task factories. *context* is no longer passed | ||
| to task factories if it is ``None``. | ||
|
|
||
| .. method:: loop.get_task_factory() | ||
|
|
||
| Return a task factory or ``None`` if the default one is in use. | ||
| Expand Down | ||
| 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. | ||
|
Comment thread
kumaraditya303 marked this conversation as resolved.
Resolved
|
||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.