From 596036b4422e2c16b55372d838ad2399eec4d6c9 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Tue, 8 Nov 2022 13:57:00 +0000 Subject: [PATCH 1/2] Clarify that every thread has its own default context in contextvars Signed-off-by: Pablo Galindo --- Doc/library/contextvars.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/contextvars.rst b/Doc/library/contextvars.rst index 08a7c7d74eab97..a05bcd22d03e0a 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 behave in a similar + fashion to :func:`threading.local()` when values are assigned in differeent + threads. + Context implements the :class:`collections.abc.Mapping` interface. .. method:: run(callable, *args, **kwargs) From 4b6e695c6fe296da16de26bcc1605b4942fd5795 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Tue, 20 Dec 2022 10:09:24 +0000 Subject: [PATCH 2/2] Update Doc/library/contextvars.rst Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com> --- Doc/library/contextvars.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/contextvars.rst b/Doc/library/contextvars.rst index a05bcd22d03e0a..0ac2f3d85749b7 100644 --- a/Doc/library/contextvars.rst +++ b/Doc/library/contextvars.rst @@ -145,8 +145,8 @@ Manual Context Management :func:`~contextvars.copy_context` function. Every thread will have a different top-level :class:`~contextvars.Context` - object. This means that a :class:`ContextVar` object behave in a similar - fashion to :func:`threading.local()` when values are assigned in differeent + 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.