Clarify that every thread has its own default context in contextvars … · python/cpython@1332fda

GitHub

Original file line numberDiff line numberDiff line change@@ -144,6 +144,11 @@ Manual Context Management

144144 To get a copy of the current context use the

145145:func:`~contextvars.copy_context` function.

146146147+ Every thread will have a different top-level :class:`~contextvars.Context`

148+ object. This means that a :class:`ContextVar` object behaves in a similar

149+ fashion to :func:`threading.local()` when values are assigned in different

150+ threads.

151+147152 Context implements the :class:`collections.abc.Mapping` interface.

148153149154 .. method:: run(callable, *args, **kwargs)