Skip to content

Commit 487bd2d

Browse files
authored
gh-142119: Clarify that one contextvars.Token can only reset once in a lifetime (GH-143693)
1 parent 3e9a5b0 commit 487bd2d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Doc/library/contextvars.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ Context Variables
119119
# After the reset call the var has no value again, so
120120
# var.get() would raise a LookupError.
121121

122+
The same *token* cannot be used twice.
123+
122124

123125
.. class:: Token
124126

125127
*Token* objects are returned by the :meth:`ContextVar.set` method.
126128
They can be passed to the :meth:`ContextVar.reset` method to revert
127129
the value of the variable to what it was before the corresponding
128-
*set*.
130+
*set*. A single token cannot reset a context variable more than once.
129131

130132
Tokens support the :ref:`context manager protocol <context-managers>`
131133
to automatically reset context variables. See :meth:`ContextVar.set`.

0 commit comments

Comments
 (0)