celery / django-celery-results

Celery result back end with django

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to use shadow_name as the result task name?

marcio0 opened this issue · comments

I have a generic command to run any django management command by informing on args which command is to be run:

@app.task(name="run_management_command")
def run_management_command(command, *args, **kwargs):
    print(f"Running '{command}' with args='{args}' and kwargs='{kwargs}'")
    call_command(command, *args, **kwargs)

And on my schedule I set it up like this:

    "generate_reports": {
        "task": "run_management_command",
        "args": ("generate_reports",),
        # every day at 6pm
        "schedule": crontab(hour=18, minute=0),
        "options": {
            "shadow": "custom_name"
        },
    },

The "shadow" argument works for changing the name shown on the logs:

2023-03-29 18:32:15,729: INFO/ForkPoolWorker-4] Task custom_name[ea4bae5f-d482-4b01-90b0-7e6cc610bdc0] succeeded in 0.007948291007778607s: None

But on the task result it still shows as the actual task name:
image

Is there a way to make the task result respect the tasks's shadow name? I have tried other ways to configure it, but it's always ignored.