aioplus.CallerThreadExecutor¶
- class aioplus.CallerThreadExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=())¶
An executor that uses the caller thread.
Examples
>>> executor = CallerThreadExecutor() >>> loop = asyncio.new_event_loop() >>> loop.set_default_executor(executor)
- Parameters:
- __exit__(exc_type, exc_val, exc_tb)[source]¶
Shutdown the executor and wait for all futures to complete.
- Parameters:
exc_type (type[BaseException] | None) – The exception type.
exc_val (BaseException | None) – The exception instance.
exc_tb (TracebackType | None) – The traceback object.
- Returns:
Reraise exceptions.
- Return type:
Literal[False]
- __init__(max_workers=None, thread_name_prefix='', initializer=None, initargs=())[source]¶
Initialize the object.
- Parameters:
max_workers (int, optional) – This parameter does not affect the behavior of the executor.
thread_name_prefix (str) – This parameter does not affect the behavior of the executor.
initializer (Callable[..., Any], optional) – This parameter does not affect the behavior of the executor.
initargs (tuple[Any, ...]) – This parameter does not affect the behavior of the executor.
- Return type:
None
Notes
Parameters are never used and serve as placeholders to comply with the interface of concurrent.futures.ThreadPoolExecutor (Liskov Substitution Principle).
- map(fn, *iterables, timeout=None, chunksize=1, buffersize=None)[source]¶
Map the callable to the iterables.
- Parameters:
- Returns:
Iterator.
- Return type:
Iterator[R]
Notes
This method submits lazily to avoid blocking the caller thread on infinite iterators;
If
timeoutis specified, thenTimeoutErroris always raised. The executor uses the caller thread, so there is no way to enforce the timeout.
- shutdown(wait=True, *, cancel_futures=False)[source]¶
Signal the executor that it should free resources.
- Parameters:
- Return type:
None
Notes
If
waitisTruethen this method will not return until all the pending futures are done executing and the resources associated with the executor have been freed. IfwaitisFalsethen this method will return immediately and the resources associated with the executor will be freed when all pending futures are done executing.