MCPcopy
hub / github.com/python-trio/trio / set

Method set

src/trio/_core/_local.py:61–76  ·  view source on GitHub ↗

Sets the value of this :class:`RunVar` for this current run call.

(self, value: T)

Source from the content-addressed store, hash-verified

59 raise LookupError(self) from None
60
61 def set(self, value: T) -> RunVarToken[T]:
62 """Sets the value of this :class:`RunVar` for this current run
63 call.
64
65 """
66 try:
67 old_value = self.get()
68 except LookupError:
69 token = RunVarToken._empty(self)
70 else:
71 token = RunVarToken[T]._create(self, old_value)
72
73 # This can't fail, because if we weren't in Trio context then the
74 # get() above would have failed.
75 _run.GLOBAL_RUN_CONTEXT.runner._locals[self] = value
76 return token
77
78 def reset(self, token: RunVarToken[T]) -> None:
79 """Resets the value of this :class:`RunVar` to what it was

Callers 15

deliverFunction · 0.45
childFunction · 0.45
first_checkFunction · 0.45
reset_checkFunction · 0.45
task1Function · 0.45
task2Function · 0.45
sync_checkFunction · 0.45
get_tokenFunction · 0.45
test_contextvar_supportFunction · 0.45
innerFunction · 0.45

Calls 3

getMethod · 0.95
_emptyMethod · 0.80
_createMethod · 0.45

Tested by 15

deliverFunction · 0.36
childFunction · 0.36
first_checkFunction · 0.36
reset_checkFunction · 0.36
task1Function · 0.36
task2Function · 0.36
sync_checkFunction · 0.36
get_tokenFunction · 0.36
test_contextvar_supportFunction · 0.36
innerFunction · 0.36