climate_ref_celery.tasks
#
Task generation and registration for Celery
This module provides a factory function to create Celery tasks for diagnostics. These celery tasks are then registered with the Celery app to enable them to be run asynchronously.
Since the diagnostic definition may be in a different virtual environment it is not possible to directly import the provider and create the tasks in both the worker and the main process.
Instead, the tasks are registered only in the worker process. The main process can then send tasks to the worker using the task name. The main process is responsible for tracking what diagnostics have been registered and to respond to new workers coming online.
generate_task_name(provider, diagnostic)
#
Generate the name of the task for the given provider and diagnostic
register_celery_tasks(app, provider)
#
Register all tasks for the given provider
This is run on worker startup to register all tasks a given provider
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
Celery
|
The Celery app to register the tasks with |
required |
provider
|
DiagnosticProvider
|
The provider to register tasks for |
required |