scheduledexecutor package

Submodules

scheduledexecutor.base module

Provides base classes and functions.

class scheduledexecutor.base.DelayQueue(maxsize=0)

Bases: queue.Queue

Implements a simple DelayQueue on top of queue.Queue, in which an element can only be taken when its delay has expired.

get(block=True, timeout=None)

Remove and return an item from the queue.

If optional args ‘block’ is true and ‘timeout’ is None (the default), block if necessary until an item is available. If ‘timeout’ is a non-negative number, it blocks at most ‘timeout’ seconds and raises the Empty exception if no item was available within that time. Otherwise (‘block’ is false), return an item if one is immediately available, else raise the Empty exception (‘timeout’ is ignored in that case).

class scheduledexecutor.base.ScheduledFuture

Bases: concurrent.futures._base.Future

TBW

scheduledexecutor.process module

Provides ProcessPoolExecutor.

class scheduledexecutor.process.ProcessPoolExecutor(max_workers=None, mp_context=None, initializer=None, initargs=())

Bases: object

Extends concurrent.futures.ProcessPoolExecutor to enable delayed and/or recurring tasks.

property max_pool_size
property pool_size
property queued_task_count
schedule(delay: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
schedule_at_fixed_delay(initial_delay: float, delay: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
schedule_at_fixed_rate(initial_delay: float, period: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
submit(fn: Callable, *args, **kwargs) concurrent.futures._base.Future

scheduledexecutor.thread module

Provides ThreadPoolExecutor.

class scheduledexecutor.thread.ThreadPoolExecutor(max_workers: Optional[int] = None, thread_name_prefix: str = '', initializer: Optional[Callable] = None, initargs: Tuple[Any, ...] = ())

Bases: concurrent.futures.thread.ThreadPoolExecutor

Extends concurrent.futures.ThreadPoolExecutor to enable delayed and/or recurring tasks.

property max_pool_size
property pool_size
property queued_task_count
schedule(delay: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
schedule_at_fixed_delay(initial_delay: float, delay: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
schedule_at_fixed_rate(initial_delay: float, period: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
submit(fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture

Submits a callable to be executed with the given arguments.

Schedules the callable to be executed as fn(*args, **kwargs) and returns a Future instance representing the execution of the callable.

Returns:

A Future representing the given call.

Module contents

Provides executors that enable delayed and/or recurring tasks.

class scheduledexecutor.ProcessPoolExecutor(max_workers=None, mp_context=None, initializer=None, initargs=())

Bases: object

Extends concurrent.futures.ProcessPoolExecutor to enable delayed and/or recurring tasks.

property max_pool_size
property pool_size
property queued_task_count
schedule(delay: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
schedule_at_fixed_delay(initial_delay: float, delay: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
schedule_at_fixed_rate(initial_delay: float, period: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
submit(fn: Callable, *args, **kwargs) concurrent.futures._base.Future
class scheduledexecutor.ScheduledFuture

Bases: concurrent.futures._base.Future

TBW

class scheduledexecutor.ThreadPoolExecutor(max_workers: Optional[int] = None, thread_name_prefix: str = '', initializer: Optional[Callable] = None, initargs: Tuple[Any, ...] = ())

Bases: concurrent.futures.thread.ThreadPoolExecutor

Extends concurrent.futures.ThreadPoolExecutor to enable delayed and/or recurring tasks.

property max_pool_size
property pool_size
property queued_task_count
schedule(delay: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
schedule_at_fixed_delay(initial_delay: float, delay: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
schedule_at_fixed_rate(initial_delay: float, period: float, fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture
submit(fn: Callable, *args, **kwargs) scheduledexecutor.base.ScheduledFuture

Submits a callable to be executed with the given arguments.

Schedules the callable to be executed as fn(*args, **kwargs) and returns a Future instance representing the execution of the callable.

Returns:

A Future representing the given call.