Skip to content

Celery

run(context, detach=False)

Start celery worker.

Source code in saritasa_invocations/celery.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@invoke.task
def run(
    context: invoke.Context,
    detach: bool = False,
) -> None:
    """Start celery worker."""
    config = _config.Config.from_context(context).celery
    match python.get_python_env():
        case python.PythonEnv.LOCAL:
            docker.up(context)
            context.run(
                config.local_cmd.format(
                    app=config.app,
                    scheduler=config.scheduler,
                    loglevel=config.loglevel,
                    extra_params=" ".join(config.extra_params),
                ),
            )
        case python.PythonEnv.DOCKER:
            docker.up_containers(
                context,
                (config.service_name,),
                detach=detach,
            )

send_task(context, task)

Send task to celery worker.

Source code in saritasa_invocations/celery.py
32
33
34
35
36
37
38
39
@invoke.task
def send_task(
    context: invoke.Context,
    task: str,
) -> None:
    """Send task to celery worker."""
    config = _config.Config.from_context(context).celery
    python.run(context, f"-m celery --app {config.app} call {task}")