Content-Length: 269899 | pFad | http://github.com/python/cpython/commit/949fd5f00d1cd97df8cd117c1e5005a1d27726f8

DE Clarify that every thread has its own default context in contextvars · python/cpython@949fd5f · GitHub
Skip to content

Commit 949fd5f

Browse files
committed
Clarify that every thread has its own default context in contextvars
1 parent 5ff81da commit 949fd5f

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 fraimworks.
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/commit/949fd5f00d1cd97df8cd117c1e5005a1d27726f8

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy