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

Method run

contextvars/__init__.py:30–41  ·  view source on GitHub ↗
(self, callable, *args, **kwargs)

Source from the content-addressed store, hash-verified

28 self._prev_context = None
29
30 def run(self, callable, *args, **kwargs):
31 if self._prev_context is not None:
32 raise RuntimeError(
33 'cannot enter context: {} is already entered'.format(self))
34
35 self._prev_context = _get_context()
36 try:
37 _set_context(self)
38 return callable(*args, **kwargs)
39 finally:
40 _set_context(self._prev_context)
41 self._prev_context = None
42
43 def copy(self):
44 new = Context()

Callers 15

wrapperFunction · 0.95
test_context_run_1Method · 0.95
test_context_run_2Method · 0.95
test_context_run_3Method · 0.95
test_context_run_4Method · 0.95
test_context_run_5Method · 0.95
test_context_run_6Method · 0.95
test_context_run_7Method · 0.95
test_context_getset_3Method · 0.95
test_context_getset_4Method · 0.95
test_context_copy_1Method · 0.95
__init__.pyFile · 0.80

Calls 2

_get_contextFunction · 0.85
_set_contextFunction · 0.85

Tested by 15

wrapperFunction · 0.76
test_context_run_1Method · 0.76
test_context_run_2Method · 0.76
test_context_run_3Method · 0.76
test_context_run_4Method · 0.76
test_context_run_5Method · 0.76
test_context_run_6Method · 0.76
test_context_run_7Method · 0.76
test_context_getset_3Method · 0.76
test_context_getset_4Method · 0.76
test_context_copy_1Method · 0.76
func1Method · 0.64