Backends

class ExecutorBackend(value)[source]

Bases: StrEnum

Enum representing the available executor backends.

Parameters:

StrEnum (_type_) – String-based enum for executor backends.

THREAD = 'thread'
PROCESS = 'process'
INTERPRETER = 'interpreter'

Backend helpers

class ExecutorBackend(value)[source]

Bases: StrEnum

Enum representing the available executor backends.

Parameters:

StrEnum (_type_) – String-based enum for executor backends.

THREAD = 'thread'
PROCESS = 'process'
INTERPRETER = 'interpreter'
normalize_backend(backend)[source]

Normalize the backend to an ExecutorBackend enum.

Parameters:

backend (ExecutorBackend | str) – The backend to normalize.

Raises:

ValueError – If the backend is not supported.

Returns:

The normalized backend.

Return type:

ExecutorBackend

resolve_executor_cls(backend)[source]

Resolve the executor class for the given backend.

Parameters:

backend (ExecutorBackend | str) – The backend to resolve.

Raises:
Returns:

The executor class for the given backend.

Return type:

type[Executor]

build_executor(*, backend, max_workers, name_prefix, executor_seq, executor_kwargs)[source]

Build an executor instance for the selected backend.

thread_name_prefix is valid for ThreadPoolExecutor and InterpreterPoolExecutor, but not for ProcessPoolExecutor on Python 3.11.

Return type:

Executor

Parameters: