Celery:在循环中调用芹菜任务时的TypeError

时间:2015-10-04 14:32:15

标签: python celery celery-task

在循环中调用芹菜任务时,我得到TypeError。第一个任务运行正常,但后续任务因TypeError (function takes 1 argument 3 given)而失败。

这是函数定义:

@celery.task 
def create_thumbnails(filename, thumbnail_width, send_mail_flag=False):

这就是我调用它的方式:

for index, (image, image_name) in enumerate(images_list):
    create_thumbnails.delay(image_name,ITEM_THUMBNAIL_WIDTH)

这是我在芹菜日志中遇到的错误:

[2015-10-04 14:04:44,222: ERROR/MainProcess] Task tasks.create_thumbnails[eff8c190-5876-4e9c-8a6f-83ad530d25ff] raised unexpected: TypeError('create_thumbnails() takes exactly 1 argument (3 given)',)
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 240, in trace_task
  R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 438, in __protected_call__
  return self.run(*args, **kwargs)
TypeError: create_thumbnails() takes exactly 1 argument (3 given)

可能的原因是什么?顺便说一句,我正在使用RabbitMQ来排队任务。

0 个答案:

没有答案