[Python-checkins] Clarify that every thread has its own default context in contextvars (GH-99246)

miss-islington webhook-mailer at python.org
Tue Dec 20 06:57:14 EST 2022


https://github.com/python/cpython/commit/e8f61ede93ecbda3b2055a2e1d8c0b43b2049737
commit: e8f61ede93ecbda3b2055a2e1d8c0b43b2049737
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-12-20T03:57:08-08:00
summary:

Clarify that every thread has its own default context in contextvars (GH-99246)

(cherry picked from commit cb60b6131bc2bb11c48a15f808914d8b242b9fc5)

Co-authored-by: Pablo Galindo Salgado <Pablogsal at gmail.com>

files:
M Doc/library/contextvars.rst

diff --git a/Doc/library/contextvars.rst b/Doc/library/contextvars.rst
index be1dd0c9eb57..3580b3537348 100644
--- a/Doc/library/contextvars.rst
+++ b/Doc/library/contextvars.rst
@@ -144,6 +144,11 @@ Manual Context Management
    To get a copy of the current context use the
    :func:`~contextvars.copy_context` function.
 
+   Every thread will have a different top-level :class:`~contextvars.Context`
+   object. This means that a :class:`ContextVar` object behaves in a similar
+   fashion to :func:`threading.local()` when values are assigned in different
+   threads.
+
    Context implements the :class:`collections.abc.Mapping` interface.
 
    .. method:: run(callable, *args, **kwargs)



More information about the Python-checkins mailing list