def start_request(self, context=None) -> Union[threadFuture, asyncFuture]: """ 将请求交给工作线程池进行排队处理。 在转交工作线程处理之前将当前的上下文环境拷贝一份交给工作线程。 以保持上下文的连贯性。 Args; context: 该上下文管理器允许 """ with apply_requester_context(self): new_context = copy_context_to_dict(inherit_scope=self.__inherit__) if context is None: context = {} new_context.update(context) self.progress.enqueue() return executor.submit(get_worker(self.NAME), context=new_context)
def __call__(self, *args, **kwargs): return executor.submit( get_worker('remote_apply'), args=(self._apply, ) + args, kwargs=kwargs, )
def stop(self): # 由于Requester使用的时异步停止方法,需要交由异步停止器运行 return executor.submit(get_worker('async_stopper'), args=(self._task.stop, ), force_sync=True)
def run(self): with b.apply(self.subbranch): self.setpoint() return executor.submit(get_worker('subflow'), args=(self.layer.run, ))
def stop_maker(): return executor.submit(get_worker('async_stopper'), args=(stopper, ), force_sync=True).result()