Example #1
0
 async def state(app_name):
     worker = get_worker('default')
     cli = get_client(app_name,
                      timeout=params.timeout,
                      hook=partial(client_hook, name=app_name),
                      raw=True)
     result = await executor.submit(worker, (cli.get_state, ))
     return result
Example #2
0
 async def reload(app_name):
     worker = get_worker('default')
     cli = get_client(
         app_name,
         timeout=params.timeout,
         hook=partial(client_hook, name=app_name),
         raw=True
     )
     return await executor.submit(
         worker,
         (cli.reload_conf,)
     )
Example #3
0
    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)
Example #4
0
 def __call__(self, *args, **kwargs):
     return executor.submit(
         get_worker('remote_apply'),
         args=(self._apply, ) + args,
         kwargs=kwargs,
     )
Example #5
0
 def stop(self):
     # 由于Requester使用的时异步停止方法,需要交由异步停止器运行
     return executor.submit(get_worker('async_stopper'),
                            args=(self._task.stop, ),
                            force_sync=True)
Example #6
0
 def run(self):
     with b.apply(self.subbranch):
         self.setpoint()
         return executor.submit(get_worker('subflow'),
                                args=(self.layer.run, ))
Example #7
0
 def stop_maker():
     return executor.submit(get_worker('async_stopper'),
                            args=(stopper, ),
                            force_sync=True).result()
Example #8
0
 async def stop(self) -> None:
     return await executor.submit(get_worker('stopper'),
                                  args=(self.progress.stop, ))