Skip to content

Commit 0e18375

Browse files
committed
Clarify that contextvar.Token objects are for single use
1 parent aa8578d commit 0e18375

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Doc/library/contextvars.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,14 @@ 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.
9697

9798
.. class:: Token
9899

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

104105
The token supports :ref:`context manager protocol <context-managers>`
105106
to restore the corresponding context variable value at the exit from

0 commit comments

Comments
 (0)