2๐
I encountered this problem too, and I think there is another way to help you out.
the answer of @narced133 works only if the varies of params are limited, then what if we have thousands kinds of params?
solution:
refactor your celery task
to accept a function as param, and the function will generate or get the params that are the real params for your celery task
: add_numbers
.
๐คfandyst
1๐
See the Celery documentation on periodic tasks for an example of how to call a task with arguments at a specified interval. http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#entries
In your example, you could use something like:
from celery.schedules import crontab
CELERYBEAT_SCHEDULE = {
'T1': {
'task': 'tasks.add_numbers',
'schedule': crontab(hour=7, minute=30, day_of_week=1),,
'args': (4, 5)
},
'T2': {
'task': 'tasks.add_numbers',
'schedule': crontab(hour=16, minute=0),,
'args': (2, 2)
},
}
๐คnarced133
- [Django]-Django Bootstrap Integration
- [Django]-During tests, how to override a Django setting used in the urlconf?
- [Django]-How to hide a field from the HTML form in the browsable Django Rest API?
- [Django]-How to uninstall pip packages which are installed from a *.txt file?
- [Django]-Permission classess decorator is ignored. "Authentication credentials were not provided" response
Source:stackexchange.com