API: Decorators: ThreadPooled, threadpooled.¶
-
class
pooled.ThreadPooled¶ Post function to ThreadPoolExecutor.
-
__init__(func, *, loop_getter, loop_getter_need_context)¶ Parameters: - func (typing.Optional[typing.Callable[.., typing.Union[typing.Any, typing.Awaitable]]]) – function to wrap
- loop_getter (typing.Union[None, typing.Callable[.., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop]) – Method to get event loop, if wrap in asyncio task
- loop_getter_need_context (bool) – Loop getter requires function context
Note
Attributes is read-only
-
loop_getter¶ typing.Union[None, typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop]Loop getter. If None: useconcurent.futures.Future, else useEventLoopfor wrapped function.
-
loop_getter_need_context¶ bool- Loop getter will use function call arguments.
-
executor¶ ThreadPoolExecutorinstance. Class-wide.Return type: ThreadPoolExecutor
-
_func¶ typing.Optional[typing.Callable[..., typing.Union[typing.Any, typing.Awaitable]]]Wrapped function. Used for inheritance only.
-
classmethod
configure(max_workers=None)¶ Pool executor create and configure.
Parameters: max_workers (typing.Optional[int]) – Maximum workers Note
max_workers=None means CPU_COUNT * 5, it’s default value.
-
classmethod
shutdown()¶ Shutdown executor.
-
__call__(*args, **kwargs)¶ Decorator entry point.
Return type: typing.Union[concurrent.futures.Future, typing.Awaitable, typing.Callable[.., typing.Union[typing.Awaitable, concurrent.futures.Future]]]
-
-
pooled.threadpooled(func, *, loop_getter, loop_getter_need_context)¶ Post function to ThreadPoolExecutor.
Parameters: - func (typing.Optional[typing.Callable[.., typing.Union[typing.Any, typing.Awaitable]]]) – function to wrap
- loop_getter (typing.Union[None, typing.Callable[.., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop]) – Method to get event loop, if wrap in asyncio task
- loop_getter_need_context (bool) – Loop getter requires function context
Return type: typing.Union[ThreadPooled, typing.Callable[.., typing.Union[concurrent.futures.Future, typing.Awaitable]]]
Not exported, but public accessed data type:
-
class
pooled.ThreadPoolExecutor(max_workers=None)¶ Provide readers for protected attributes.
Simply extend concurrent.futures.ThreadPoolExecutor.
Parameters: max_workers (typing.Optional[int]) – Maximum workers allowed. If none: cpu_count() * 5 -
max_workers¶ int- max workers variable.
-
is_shutdown¶ bool- executor in shutdown state.
-