Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django-celery-results does not respect result_extended flag #315

Closed
AmitPhulera opened this issue May 24, 2022 · 1 comment · Fixed by #316
Closed

django-celery-results does not respect result_extended flag #315

AmitPhulera opened this issue May 24, 2022 · 1 comment · Fixed by #316

Comments

@AmitPhulera
Copy link
Contributor

Hi!

As mentioned in celery docs, by default result_extended is set to False in the celery config.

But django-celery-results store args, kwargs and other meta info despite result_extended is set to False.

Here are the reproduction steps

# tasks.py
from celery import shared_task

@shared_task
def some_task(param):
    print(f"{param} was passed")
    return param

Calling the task from django-manage shell

In [1]: from myapp.apps.niceapp.tasks import some_task

# calls the task
In [2]: some_task.delay(["input_2"])
Out[2]: <AsyncResult: ab75a9fb-061c-48a2-a4cb-e85df047e23f>

# Verifying that `result_extended` is set to `False`
In [3]: _2.app.conf.get("result_extended")
Out[3]: False

# helper to view all fields in model object
In [4]: def display_all_fields(s_obj):
   ...:     for f in s_obj._meta.fields:
   ...:         print(f.name, getattr(s_obj, f.name))

# Trying to figure out what all info is stored in db
In [5]: from django_celery_results.models import TaskResult

In [6]: TaskResult.objects.get(task_id=_2.task_id)
Out[6]: <TaskResult: <Task: ab75a9fb-061c-48a2-a4cb-e85df047e23f (SUCCESS)>>

In [7]: display_all_fields(_6)
id 19096
task_id ab75a9fb-061c-48a2-a4cb-e85df047e23f
periodic_task_name None
task_name myapp.apps.niceapp.tasks.some_task
task_args "(['input_2'],)"
task_kwargs "{}"
status SUCCESS
worker celery@work
content_type application/json
content_encoding utf-8
result ["input_2"]
date_created 2022-05-24 07:54:47.677220
date_done 2022-05-24 07:54:47.725070
traceback None
meta {"children": []}

All the metadata is logged which should be stripped.

Is there a reason to ignore this config option? If not, I would be happy to send in a PR to fix this issue.

Thanks.

@ahosie
Copy link

ahosie commented Jul 25, 2022

Stripping out the task_name property like is going to cause a lot of headaches for users of this project... myself included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants