MCPcopy Create free account
hub / github.com/MagicStack/contextvars / set

Method set

contextvars/__init__.py:108–118  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

106 raise LookupError
107
108 def set(self, value):
109 ctx = _get_context()
110 data = ctx._data
111 try:
112 old_value = data[self]
113 except KeyError:
114 old_value = Token.MISSING
115
116 updated_data = data.set(self, value)
117 ctx._data = updated_data
118 return Token(ctx, self, old_value)
119
120 def reset(self, token):
121 if token._used:

Callers 11

test_context_getset_1Method · 0.95
test_context_getset_2Method · 0.95
test_context_getset_5Method · 0.95
resetMethod · 0.80
func1Method · 0.80
funcMethod · 0.80
funMethod · 0.80
ctx1_funMethod · 0.80
ctx2_funMethod · 0.80
subMethod · 0.80

Calls 2

_get_contextFunction · 0.85
TokenClass · 0.85

Tested by 10

test_context_getset_1Method · 0.76
test_context_getset_2Method · 0.76
test_context_getset_5Method · 0.76
func1Method · 0.64
funcMethod · 0.64
funMethod · 0.64
ctx1_funMethod · 0.64
ctx2_funMethod · 0.64
subMethod · 0.64