Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
contextvars.Token
1 parent 3e9a5b0 commit 487bd2dCopy full SHA for 487bd2d
1 file changed
Doc/library/contextvars.rst
@@ -119,13 +119,15 @@ Context Variables
119
# After the reset call the var has no value again, so
120
# var.get() would raise a LookupError.
121
122
+ The same *token* cannot be used twice.
123
+
124
125
.. class:: Token
126
127
*Token* objects are returned by the :meth:`ContextVar.set` method.
128
They can be passed to the :meth:`ContextVar.reset` method to revert
129
the value of the variable to what it was before the corresponding
- *set*.
130
+ *set*. A single token cannot reset a context variable more than once.
131
132
Tokens support the :ref:`context manager protocol <context-managers>`
133
to automatically reset context variables. See :meth:`ContextVar.set`.
0 commit comments