Skip to content

Commit d6f4fb8

Browse files
[3.13] gh-142119: Clarify that one contextvars.Token can only reset once in a lifetime (GH-143693) (GH-144267)
(cherry picked from commit 487bd2d) Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
1 parent 33a488e commit d6f4fb8

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
@@ -93,13 +93,15 @@ Context Variables
9393
# After the reset call the var has no value again, so
9494
# var.get() would raise a LookupError.
9595

96+
The same *token* cannot be used twice.
97+
9698

9799
.. class:: Token
98100

99101
*Token* objects are returned by the :meth:`ContextVar.set` method.
100102
They can be passed to the :meth:`ContextVar.reset` method to revert
101103
the value of the variable to what it was before the corresponding
102-
*set*.
104+
*set*. A single token cannot reset a context variable more than once.
103105

104106
.. attribute:: Token.var
105107

0 commit comments

Comments
 (0)