\
    A decorator that wraps the decorated function into `component_coro_wrapper`.
    Note that decorated functions can not be pickled,
    so this can't be used directly for workloads being sent to different processes.
    As a workaround, instead decorate a nested function:

        async def workload(*args, commands, events, **kwargs):
            @component_workload
            async def _workload(*args, commands, events, **kwargs):
                # initialize
                await events.send(Component.EVENT_START)
                # do some work

            await _workload(*args, commands, events, **kwargs)

def component_workload(coro_func: CoroutineFunction[T]) -> CoroutineFunction[T]:
    """\
    A decorator that wraps the decorated function into `component_coro_wrapper`.
    Note that decorated functions can not be pickled,
    so this can't be used directly for workloads being sent to different processes.
    As a workaround, instead decorate a nested function:

        async def workload(*args, commands, events, **kwargs):
            @component_workload
            async def _workload(*args, commands, events, **kwargs):
                # initialize
                await events.send(Component.EVENT_START)
                # do some work

            await _workload(*args, commands, events, **kwargs)
    """
    return functools.partial(component_coro_wrapper, coro_func)