| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8f23cad commit efcd4bc
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -967,7 +967,7 @@ Introspection | |||
| 967 | 967 | Task Object | |
| 968 | 968 | =========== | |
| 969 | 969 | ||
| 970 | - .. class:: Task(coro, *, loop=None, name=None) | ||
| 970 | + .. class:: Task(coro, *, loop=None, name=None, context=None) | ||
| 971 | 971 | ||
| 972 | 972 | A :class:`Future-like <Future>` object that runs a Python | |
| 973 | 973 | :ref:`coroutine <coroutine>`. Not thread-safe. | |
@@ -1002,9 +1002,10 @@ Task Object | |||
| 1002 | 1002 | APIs except :meth:`Future.set_result` and | |
| 1003 | 1003 | :meth:`Future.set_exception`. | |
| 1004 | 1004 | ||
| 1005 | - Tasks support the :mod:`contextvars` module. When a Task | ||
| 1006 | - is created it copies the current context and later runs its | ||
| 1007 | - coroutine in the copied context. | ||
| 1005 | + An optional keyword-only *context* argument allows specifying a | ||
| 1006 | + custom :class:`contextvars.Context` for the *coro* to run in. | ||
| 1007 | + If no *context* is provided, the Task copies the current context | ||
| 1008 | + and later runs its coroutine in the copied context. | ||
| 1008 | 1009 | ||
| 1009 | 1010 | .. versionchanged:: 3.7 | |
| 1010 | 1011 | Added support for the :mod:`contextvars` module. | |
@@ -1016,6 +1017,9 @@ Task Object | |||
| 1016 | 1017 | Deprecation warning is emitted if *loop* is not specified | |
| 1017 | 1018 | and there is no running event loop. | |
| 1018 | 1019 | ||
| 1020 | + .. versionchanged:: 3.11 | ||
| 1021 | + Added the *context* parameter. | ||
| 1022 | + | ||
| 1019 | 1023 | .. method:: done() | |
| 1020 | 1024 | ||
| 1021 | 1025 | Return ``True`` if the Task is *done*. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments