MCPcopy Create free account
hub / github.com/apple/axlearn / run_with_child_context

Method run_with_child_context

axlearn/common/module_test.py:206–217  ·  view source on GitHub ↗
(child_name, context_stack)

Source from the content-addressed store, hash-verified

204 orig_stack = _global_context_stack.stack
205
206 def run_with_child_context(child_name, context_stack):
207 self.assertIsNot(context_stack, orig_stack)
208 self.assertIs(_global_context_stack.stack, orig_stack)
209 # A thread should install the cloned context stack first.
210 install_context_stack(context_stack)
211 self.assertIs(_global_context_stack.stack, context_stack)
212
213 # Now child_context() between different threads will not interfere with each other.
214 with child_context(child_name):
215 x = current_context().state["x"] # pytype: disable=attribute-error
216 xs.add(x)
217 barrier.wait()
218
219 threads = []
220 for child_name in ("child1", "child2"):

Callers

nothing calls this directly

Calls 4

install_context_stackFunction · 0.90
child_contextFunction · 0.90
current_contextFunction · 0.90
addMethod · 0.80

Tested by

no test coverage detected