Skip to content

async_task

Decorator to turn an async def function into a runnable task, for use with AsyncWorker. See tasks.task for the sync equivalent.

Parameters:

Name Type Description Default
function Callable

An async def function you want to run as a task. It should take a TaskInfo as first argument.

required
Source code in src/alchemical_queues/tasks/aio.py
162
163
164
165
166
167
168
169
170
171
172
173
174
def async_task(
    function: Callable[Concatenate[TaskInfo, Param], Awaitable[RValue]],
) -> AsyncTasker[Param, RValue]:
    """Decorator to turn an `async def` function into a runnable task, for
    use with [AsyncWorker][alchemical_queues.tasks.aio.AsyncWorker]. See
    [tasks.task][alchemical_queues.tasks.task] for the sync equivalent.

    Args:
        function (Callable): An `async def` function you want to run as a
            task. It should take a [TaskInfo][alchemical_queues.tasks.TaskInfo]
            as first argument.
    """
    return AsyncTasker[Param, RValue](function)