Skip to content

Commit

Permalink
Newsfragment + doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuyukai committed Dec 23, 2021
1 parent 506d7c8 commit 885b888
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/source/reference-core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,12 @@ Example output (yours may differ slightly):
request 0: Helper task b finished
request 0: Request received finished
You can change the current :class:`contextvars.Context` a task is running
in with a helper context manager.

.. autofunction:: change_context
:async-with:

For more information, read the
`contextvar docs <https://docs.python.org/3.7/library/contextvars.html>`__.

Expand Down
2 changes: 2 additions & 0 deletions newsfragments/2086.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add an API to allow changing the current Context a task is running
in.
2 changes: 1 addition & 1 deletion trio/_core/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


@asynccontextmanager
async def change_context(context: Context):
async def change_context(context):
"""Asynchronous context manager to change the :class:`contextvars.Context`
for the current task.
Expand Down

0 comments on commit 885b888

Please sign in to comment.