本文整理匯總了Python中concurrent.futures._base.Executor方法的典型用法代碼示例。如果您正苦於以下問題:Python _base.Executor方法的具體用法?Python _base.Executor怎麽用?Python _base.Executor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類concurrent.futures._base
的用法示例。
在下文中一共展示了_base.Executor方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from concurrent.futures import _base [as 別名]
# 或者: from concurrent.futures._base import Executor [as 別名]
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()
示例2: post
# 需要導入模塊: from concurrent.futures import _base [as 別名]
# 或者: from concurrent.futures._base import Executor [as 別名]
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')
示例3: _start_queue_management_thread
# 需要導入模塊: from concurrent.futures import _base [as 別名]
# 或者: from concurrent.futures._base import Executor [as 別名]
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
示例4: _make_executor
# 需要導入模塊: from concurrent.futures import _base [as 別名]
# 或者: from concurrent.futures._base import Executor [as 別名]
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)