Python concurrent.futures._base.Executor() Examples
The following are 6
code examples of concurrent.futures._base.Executor().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
concurrent.futures._base
, or try the search function
.
Example #1
Source File: multiple_executor.py From agents-aea with Apache License 2.0 | 6 votes |
def __init__( self, tasks: Sequence[AbstractExecutorTask], task_fail_policy=ExecutorExceptionPolicies.propagate, ) -> None: """ Init executor. :param tasks: sequence of AbstractExecutorTask instances to run. :param task_fail_policy: the exception policy of all the tasks """ self._task_fail_policy: ExecutorExceptionPolicies = task_fail_policy self._tasks: Sequence[AbstractExecutorTask] = tasks self._is_running: bool = False self._future_task: Dict[Awaitable, AbstractExecutorTask] = {} self._loop: AbstractEventLoop = asyncio.new_event_loop() self._executor_pool: Optional[Executor] = None self._set_executor_pool()
Example #2
Source File: multiple_executor.py From agents-aea with Apache License 2.0 | 6 votes |
def __init__( self, mode: str, fail_policy=ExecutorExceptionPolicies.propagate ) -> None: """ Init with selected executor mode. :param mode: one of supported executor modes :param fail_policy: one of ExecutorExceptionPolicies to be used with Executor """ if mode not in self.SUPPORTED_MODES: raise ValueError(f"Unsupported mode: {mode}") self._mode: str = mode self._executor: AbstractMultipleExecutor = self._make_executor( mode, fail_policy ) self._thread: Optional[Thread] = None
Example #3
Source File: _base_actor.py From ibeis with Apache License 2.0 | 5 votes |
def post(self, message): """ analagous to _base.Executor.submit, but sends a message to the actor controlled by this Executor, and returns a Future. """ raise NotImplementedError( 'use ProcessActorExecutor or ThreadActorExecutor')
Example #4
Source File: process.py From Imogen with MIT License | 5 votes |
def _start_queue_management_thread(self): if self._queue_management_thread is None: # When the executor gets garbarge collected, the weakref callback # will wake up the queue management thread so that it can terminate # if there is no pending work item. def weakref_cb(_, thread_wakeup=self._queue_management_thread_wakeup): mp.util.debug('Executor collected: triggering callback for' ' QueueManager wakeup') thread_wakeup.wakeup() # Start the processes so that their sentinels are known. self._adjust_process_count() self._queue_management_thread = threading.Thread( target=_queue_management_worker, args=(weakref.ref(self, weakref_cb), self._processes, self._pending_work_items, self._work_ids, self._call_queue, self._result_queue, self._queue_management_thread_wakeup), name="QueueManagerThread") self._queue_management_thread.daemon = True self._queue_management_thread.start() _threads_wakeups[self._queue_management_thread] = \ self._queue_management_thread_wakeup
Example #5
Source File: multiple_executor.py From agents-aea with Apache License 2.0 | 5 votes |
def _make_executor( self, mode: str, fail_policy: ExecutorExceptionPolicies ) -> AbstractMultipleExecutor: """ Make an executor instance to run agents with. :param mode: executor mode to use. :param fail_policy: one of ExecutorExceptionPolicies to be used with Executor :return: aea executor instance """ executor_cls = self.SUPPORTED_MODES[mode] return executor_cls(tasks=self._make_tasks(), task_fail_policy=fail_policy)
Example #6
Source File: process.py From android_universal with MIT License | 5 votes |
def _start_queue_management_thread(self): if self._queue_management_thread is None: # When the executor gets garbarge collected, the weakref callback # will wake up the queue management thread so that it can terminate # if there is no pending work item. def weakref_cb(_, thread_wakeup=self._queue_management_thread_wakeup): mp.util.debug('Executor collected: triggering callback for' ' QueueManager wakeup') thread_wakeup.wakeup() # Start the processes so that their sentinels are known. self._adjust_process_count() self._queue_management_thread = threading.Thread( target=_queue_management_worker, args=(weakref.ref(self, weakref_cb), self._processes, self._pending_work_items, self._work_ids, self._call_queue, self._result_queue, self._queue_management_thread_wakeup), name="QueueManagerThread") self._queue_management_thread.daemon = True self._queue_management_thread.start() _threads_wakeups[self._queue_management_thread] = \ self._queue_management_thread_wakeup