Worker Manager Mixin

autoscale_worker_manager_mixin module

Fixed Worker Manager Mixin.

class aio_parallel_tools.aio_task_pool.core.mixins.worker_manager_mixin.autoscale_worker_manager_mixin.AutoScaleWorkerManagerMixin(*, min_size: int = 3, max_size: Optional[int] = None, auto_scale_interval: int = 10, auto_scale_cache_len: int = 20, executor: concurrent.futures._base.Executor = None)[源代码]

基类:object

Auto scale Worker Manager Mixin.

依赖

loop (Property): event loop.

queue (Property): message queue.

make_close_signal (Method): Make close signal to send.

parser_message (Method): Parser messages from queue.

waiting_tasks_number (Property): Now number of the waiting tasks.

paused (Property): Check if user can submit tasks.

提供

size (Property): worker set's size.

start_workers (Asynchronous Method): Initialize workers and open the task pool to accept tasks.

scale (Asynchronous Method): Scale the number of the task pool's worker.

scale_nowait (Method): Scale the number of the task pool's worker without waiting.

close_workers (Asynchronous Method): Send worker pool size's close signal to the queue.

close_workers_nowait_soft (Method): Send worker pool size's close signal to the queue with no wait.

close_workers_hard (Method): Cancel worker hardlly.

close_auto_scale_worker (Method): Close auto scale worker.

close_auto_scale_worker()[源代码]

Close _auto_scale_worker.

async close_workers()[源代码]

Send worker pool size's close signal to the queue.

close_workers_hard() → None[源代码]

Cancel worker hardlly.

close_workers_nowait_soft() → None[源代码]

Send worker pool size's close signal to the queue with no wait.

async scale(num: int) → int[源代码]

Scale the number of the task pool's worker.

参数

num (int) -- num to scale.positive will increase the worker,negative will decrease the worker.

返回

the number will scale to.

返回类型

int

scale_nowait(num: int, soft=True) → int[源代码]

Scale the number of the task pool's worker without waiting.

参数
  • num (int) -- num to scale.positive will increase the worker,negative will decrease the worker.

  • soft (bool, optional) -- if True, this interface will send Signal to task pool to close workers; else number of random workers will be cancel. Defaults to True.

返回

the number will scale to.

返回类型

int

property size

Pool's size.

返回

Pool's size

返回类型

int

async start_auto_scale() → None[源代码]
async start_workers() → None[源代码]

Initialize workers and open the task pool to accept tasks.

fix_worker_manager_mixin module

Fixed Worker Manager Mixin.

class aio_parallel_tools.aio_task_pool.core.mixins.worker_manager_mixin.fix_worker_manager_mixin.FixedWorkerManagerMixin(init_size: int = 3, executor: concurrent.futures._base.Executor = None)[源代码]

基类:object

Fixed Worker Manager Mixin.

依赖

loop (Property): event loop.

queue (Property): message queue.

make_close_signal (Method): Make close signal to send.

parser_message (Method): Parser messages from queue.

提供

size (Property): worker set's size.

start_workers (Asynchronous Method): Initialize workers and open the task pool to accept tasks.

scale (Asynchronous Method): Scale the number of the task pool's worker.

scale_nowait (Method): Scale the number of the task pool's worker without waiting.

close_workers (Asynchronous Method): Send worker pool size's close signal to the queue.

close_workers_nowait_soft (Method): Send worker pool size's close signal to the queue with no wait.

close_workers_hard (Method): Cancel worker hardlly.

async close_workers()[源代码]

Send worker pool size's close signal to the queue.

close_workers_hard() → None[源代码]

Cancel worker hardlly.

close_workers_nowait_soft() → None[源代码]

Send worker pool size's close signal to the queue with no wait.

async scale(num: int) → int[源代码]

Scale the number of the task pool's worker.

参数

num (int) -- num to scale.positive will increase the worker,negative will decrease the worker.

返回

the number will scale to.

返回类型

int

scale_nowait(num: int, soft=True) → int[源代码]

Scale the number of the task pool's worker without waiting.

参数
  • num (int) -- num to scale.positive will increase the worker,negative will decrease the worker.

  • soft (bool, optional) -- if True, this interface will send Signal to task pool to close workers; else number of random workers will be cancel. Defaults to True.

返回

the number will scale to.

返回类型

int

property size

Pool's size.

返回

Pool's size

返回类型

int

async start_workers() → None[源代码]

Initialize workers and open the task pool to accept tasks.