Reputation: 7202
The Celery docs describe how you can pass positional arguments to your beat-scheduled tasks as a list or tuple.
I have a task that takes a single argument, a list of integers:
@shared_task
def schedule_by_ids(ids):
...
My celerybeat schedule looks like this:
CELERYBEAT_SCHEDULE = {
'schedule_by_ids': {
'task': 'myproj.app.tasks.schedule_by_ids',
'schedule': crontab(minute='*/10', hour='8-21'),
'args': ([1,]),
},
}
My task fails with an "int is not iterable" TypeError
. According the my monitor (celery flower) the args are passed as [1]
.
When I make the args a list, like [[1]]
, the arg shows up in the monitor as [[1]]
and it works fine.
My questions are: How is it passing the args when it is a tuple? Why?
Upvotes: 1
Views: 2473
Reputation: 280563
([1,])
That's not a tuple. That's just [1,]
in grouping parentheses. If you want a 1-element tuple, you need to put a comma in it like so, to distinguish it from just a parenthesized expression:
([1,],)
I suspect you may have misplaced the comma, and you meant to do this:
([1],)
Upvotes: 7