(
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,
)
| 242 | |
| 243 | |
| 244 | def 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) |
nothing calls this directly
no test coverage detected