Base executors: thread_pool, process_pool, sync

concurrent.futures

A few convenience methods are provided for the creation of concurrent.futures executors. The executors produced by these methods include the more_executors.Executors with_* methods for Composing executors.

classmethod Executors.thread_pool(*args, **kwargs)

Create a thread pool executor.

Returns

a new executor, initialized with the given arguments

Return type

ThreadPoolExecutor

classmethod Executors.process_pool(*args, **kwargs)

Create a process pool executor.

Returns

a new executor, initialized with the given arguments

Return type

ProcessPoolExecutor

Sync

SyncExecutor is a base executor which invokes any submitted callables immediately in the calling thread.

class more_executors.SyncExecutor(logger=None, name='default')

An executor which immediately invokes all submitted callables.

Parameters
  • logger (Logger) – a logger used for messages from this executor

  • name (str) – a name for this executor

Changed in version 2.7.0: Introduced name.

submit(fn, *args, **kwargs)

Immediately invokes fn(*args, **kwargs) and returns a future with the result (or exception).

classmethod Executors.sync(logger=None)

Creates a new synchronous executor.

Returns

a new synchronous executor

Return type

SyncExecutor

Submitted functions will be immediately invoked on the calling thread.