Skip to content

async_manager

AsyncManager

A static manager for asynchronous execution in a synchronous context.

By default, it uses MainThreadExecutor. To enable multithreading, call enable_multithreading() to switch to multithreaded event loops.

get_executor staticmethod

get_executor() -> IAsyncExecutor

Get the current executor used by AsyncManager.

Returns:

Type Description
IAsyncExecutor

An object that implements the IAsyncExecutor interface.

set_executor staticmethod

set_executor(executor: IAsyncExecutor) -> None

Replace the current asynchronous executor used by AsyncManager with a new executor.

Parameters:

Name Type Description Default
executor IAsyncExecutor

An object that implements the IAsyncExecutor interface, responsible for managing and executing asynchronous tasks.

required

Returns:

Type Description
None

None.

enable_multithreading staticmethod

enable_multithreading(pool_size: int = 3) -> None

Switch to a multithreaded executor. Tasks will then be dispatched to background threads.

disable_multithreading staticmethod

disable_multithreading() -> None

Switch back to the main thread executor.