Task execution
TaskExecutor chooses an execution strategy from the scheme of the route
(task:// or lambda://). To support a new scheme, subclass
TaskExecutionStrategy and register it in TaskExecutor.strategies.
Executor
Strategy interface
Local strategy (task://)
- class celery_cloud.runners.local_strategy.LocalTaskExecutionStrategy[source]
Bases:
TaskExecutionStrategyRun the task as a python function packaged with the runner.
The route is
task://<module>/<function>. The function is called with two positional parameters: the list of positional arguments and the dict of keyword arguments, i.e.function(args, kwargs). A function decorated withcelery_cloud.taskis called with its natural arguments instead (seecelery_cloud.tasks).
- celery_cloud.runners.local_strategy.load_function(route: TaskRoute) Any[source]
Import the function of a
task://<module>/<function>route.Module and function come from the TASKS setting (trusted, deployed with the runner), never from the message.
- celery_cloud.runners.local_strategy.task_options(route: TaskRoute) TaskOptions | None[source]
The
@taskoptions of a local route (None for a plain function).Best effort: if the function cannot be imported, None is returned and executing the task reports the real error.
Lambda strategy (lambda://)
- exception celery_cloud.runners.lambda_strategy.LambdaFunctionError(message: str, detail: str | None = None)[source]
Bases:
TaskExecutionExceptionThe remote function ran and reported an error.
It is neither retried (the code already executed and may have side effects) nor counted by the circuit breaker (it is a business error, not an infrastructure failure).
- exception celery_cloud.runners.lambda_strategy.LambdaInvocationError(message: str, detail: str | None = None)[source]
Bases:
TaskExecutionExceptionThe remote function could not be invoked (throttling, network…).
It is safe to retry: the function did not run.
- class celery_cloud.runners.lambda_strategy.LambdaTaskExecutionStrategy[source]
Bases:
TaskExecutionStrategy