celery bind = True导致异常

时间:2016-01-03 17:44:24

标签: python data-structures celery

我使用Celery v3.1.19执行任务,此任务调用一个函数,其中一个参数是字典。当 bind = True

时,我总是会遇到此错误
[2016-01-03 09:33:41,883: ERROR/MainProcess] Task hypervisor.esxi.deploy_esx.imbue_esx[21A2B368B2] raised unexpected: TypeError("imbue_esx() got multiple values for keyword argument 'configuration'",)
Traceback (most recent call last):
  File "/Users/gogasca/Documents/OpenSource/Development/Python/IMBUExApp/venv/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/Users/gogasca/Documents/OpenSource/Development/Python/IMBUExApp/venv/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
TypeError: imbue_esx() got multiple values for keyword argument 'configuration'

当我看到函数imbue_esx定义如下:

@task(bind=True)
def imbue_esx(
        configuration={},
        job="1",        
        api_call=False,
        cli=False,
        manual_mode=False,
        log_file="",
        **kwargs):

这就是我发送此任务的方式:

 celery.send_task("hypervisor.esxi.deploy_esx.imbue_esx",                                                
                                             kwargs={'configuration': configuration,
                                                   'job':job_ref,                                                      
                                                   'api_call': True },
                                             task_id=job_ref)

我试过像这样调用imbue_esx:

celery.send_task("hypervisor.esxi.deploy_esx.imbue_esx",
                                             kwargs={'configuration': configuration,
                                                     'job':job_ref,                                                       
                                                     'api_call': True,
                                                     'cli': False,
                                                     'manual_mode': False,
                                                     'log_file': ""},

甚至从**kwargs删除imbue_esx,但总是会遇到同样的错误。有什么想法吗?

DEBUG

[2016-01-03 09:33:41,821: INFO/MainProcess] Received task: hypervisor.esxi.deploy_esx.imbue_esx[21A2B368B2]
[2016-01-03 09:33:41,821: DEBUG/MainProcess] TaskPool: Apply <function _fast_trace_task at 0x10fa219b0> (args:('hypervisor.esxi.deploy_esx.imbue_esx', '21A2B368B2', [], {'job': '21A2B368B2', 'api_call': True, 'job_id': 236, 'configuration': {'host': {u'hypervisor': {u'username': u'root', u'vnc': u'5900:5909', u'name': u'esx-milpitas', u'ip': u'110.10.0.144', u'discover': True, u'sync': True, u'ssh': 22, u'https': 443, u'password': u'password', u'type': u'esxi', u'owner_id': 1}, u'db': True}}}, {'utc': True, u'is_eager': False, 'chord': None, u'group': None, 'args': [], 'retries': 0, u'delivery_info': {u'priority': 0, u'redelivered': False, u'routing_key': u'celery', u'exchange': u'celery'}, 'expires': None, u'hostname': 'celery@gonzo.local', 'task': 'hypervisor.esxi.deploy_esx.imbue_esx', 'callbacks': None, u'correlation_id': u'21A2B368B2', 'errbacks': None, 'timelimit': (None, None), 'taskset': None, 'kwargs': {'job': '21A2B368B2', 'api_call': True, 'job_id': 236, 'configuration': {'host': {u'hypervisor': {u'username': u'root', u'vnc': u'5900:5909', u'name': u'esx-milpitas', u'ip': u'110.10.0.144', u'discover':... kwargs:{})

1 个答案:

答案 0 :(得分:1)

我已升级到v3.1.19并将 self 参数添加到imbue_esx函数中。