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

This commit is contained in:
Pablo Galindo Salgado 2022-12-20 11:35:48 +00:00 committed by GitHub
parent d98ca8172c
commit cb60b6131b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -144,6 +144,11 @@ Manual Context Management
To get a copy of the current context use the To get a copy of the current context use the
:func:`~contextvars.copy_context` function. :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. Context implements the :class:`collections.abc.Mapping` interface.
.. method:: run(callable, *args, **kwargs) .. method:: run(callable, *args, **kwargs)