Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit949fd5f

Browse files
committed
Clarify that every thread has its own default context in contextvars
1 parent5ff81da commit949fd5f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎Doc/library/contextvars.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ and work with *Context Variables*. The :func:`~contextvars.copy_context`
1414
function and the:class:`~contextvars.Context` class should be used to
1515
manage the current context in asynchronous frameworks.
1616

17+
..note::
18+
By default, every thread will have a different default
19+
:class:`~contextvars.Context`. This means that a
20+
:class:`~contextvars.ContextVar` can generally be used as a drop-in
21+
replacement for a:func:`threading.local` variable.
22+
1723
Context managers that have state should use Context Variables
1824
instead of:func:`threading.local()` to prevent their state from
1925
bleeding to other code unexpectedly, when used in concurrent code.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp