本文整理汇总了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)