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

Arguments included in the one parameter can not be optional #143

Open
ErikKalkoken opened this issue Sep 15, 2023 · 0 comments
Open

Arguments included in the one parameter can not be optional #143

ErikKalkoken opened this issue Sep 15, 2023 · 0 comments

Comments

@ErikKalkoken
Copy link

When we have a task like this:

@celery.task(base=QueueOnce, once={"keys": ["alpha"], "graceful": True})
def example(alpha=None):
    ...

And you call the task without the optional argument like this:

example.delay()

You get an error in celery_once. Apparently, optional arguments are not supported in this context.

Traceback (most recent call last):
  File "/home/erik/python/projects/aa-dev/venv/lib/python3.10/site-packages/celery/app/trace.py", line 569, in trace_task
    task_after_return(
  File "/home/erik/python/projects/aa-dev/venv/lib/python3.10/site-packages/celery_once/tasks.py", line 140, in after_return
    key = self.get_key(args, kwargs)
  File "/home/erik/python/projects/aa-dev/venv/lib/python3.10/site-packages/celery_once/tasks.py", line 129, in get_key
    key = queue_once_key(self.name, call_args, restrict_to)
  File "/home/erik/python/projects/aa-dev/venv/lib/python3.10/site-packages/celery_once/helpers.py", line 71, in queue_once_key
    restrict_kwargs = {key: kwargs[key] for key in restrict_to}
  File "/home/erik/python/projects/aa-dev/venv/lib/python3.10/site-packages/celery_once/helpers.py", line 71, in <dictcomp>
    restrict_kwargs = {key: kwargs[key] for key in restrict_to}
KeyError: 'alpha'

This should at least be mentioned in the README or better yet it should be implemented.

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

No branches or pull requests

1 participant