-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add new setting: 'task_args_repr_function'. #6595
base: main
Are you sure you want to change the base?
Conversation
it will tke sometime to review & reach a consensus. I will start tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few comments.
This requires tests to be merged, as well.
@cached_property | ||
def repr(self): | ||
repr_function = self.app.conf.task_args_repr_function | ||
if not repr_function: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, this fallback is inappropriate for most if not all cases.
We should raise an ImproperlyConfigured
exception instead if that is the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With task_protocol=1, the backend receives the original args
and kwargs
values (i.e. as tuple
and dict
)
With this fallback I was trying to get the same.
Anyway, I will just raise ImproperlyConfigured
as you suggest.
Explicit is better than implicit.
if not repr_function: | ||
return lambda o, **kwargs: o | ||
elif isinstance(repr_function, str): | ||
return mlazy(symbol_by_name, repr_function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should test if repr_function
is a callable.
If it isn't this should also raise an ImproperlyConfigured
exception.
``task_args_repr_function`` | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
.. versionadded: 5.? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. versionadded: 5.? | |
.. versionadded: 5.1 |
@arnau126 This is a friendly ping to remind you to complete this pull request. |
@arnau126 If you don't have time to finish this PR I can take over. |
@auvipy Hey, sure thing I can take over. |
ok great |
Hi all, |
no one is working. you can take over |
any further progress on it? |
no we need new contributors to take this over |
Description
Add new setting:
task_args_repr_function
(perhaps there is a more appropriate name).This setting allows you to choose which function do you want to use to generate
argsrepr
andkwargsrepr
(the string representation of the task args and kwargs used for logging purposes).Default is
"celery.utils.saferepr.saferepr"
which is the currently used function.Examples
so it will be easier to parse them later on in some backends like the one of
django-celery-results
.or
so we don't have to specify
kwargsrepr
param at each task call.Tests
Tests not done yet. Please let me know if you agree with this approach, and I will add some tests.