def __init__(self, parent_proc=None, *args, **kwargs): # print("thread layer init") super().__init__(*args, **kwargs) if parent_proc is not None: self.thread = parent_proc.register_child_thread(self) LayerManager.session().add_layer(self, only_monitor=True) else: self.create_thread() LayerManager.session().add_layer(self)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) ctx = multiprocessing.get_context('spawn') self.process = ctx.Process(target=self.run_proc) self.thread_layers = [] LayerManager.session().add_layer(self)
def register_child_thread(self, *args, **kwargs): # threads can't have child threads. Pass along to parent proc. self.create_thread() LayerManager.session().add_layer(self)