MCPcopy Create free account
hub / github.com/MAC-VO/MAC-VO / IOptimizerParallelWorker

Function IOptimizerParallelWorker

Module/Optimization/Interface.py:244–264  ·  view source on GitHub ↗
(
    config: SimpleNamespace,
    init_context: T.Callable[[SimpleNamespace,], T_Context],
    optimize: T.Callable[[T_Context, T_GraphInput], tuple[T_Context, T_GraphOutput]],
    child_conn: Conn_Type,
)

Source from the content-addressed store, hash-verified

242
243
244def IOptimizerParallelWorker(
245 config: SimpleNamespace,
246 init_context: T.Callable[[SimpleNamespace,], T_Context],
247 optimize: T.Callable[[T_Context, T_GraphInput], tuple[T_Context, T_GraphOutput]],
248 child_conn: Conn_Type,
249):
250 Logger.write("info", "OptimizationParallelWorker started")
251 # NOTE: child process ignore keyboard interrupt to ignore deadlock
252 # (parent process will terminate child process on exit in MAC-VO implementation)
253 signal.signal(signal.SIGINT, signal.SIG_IGN)
254 torch.set_num_threads(8)
255 context = init_context(config)
256 while True:
257 if not child_conn.poll(timeout=0.1): continue
258
259 graph_args: T_GraphInput = child_conn.recv()
260 graph_args_local = move_dataclass_to_local(graph_args)
261 del graph_args
262
263 context, graph_res = optimize(context, graph_args_local)
264 child_conn.send(graph_res)

Callers

nothing calls this directly

Calls 2

move_dataclass_to_localFunction · 0.85
writeMethod · 0.80

Tested by

no test coverage detected