Python celery配置返回交换错误

时间:2019-01-05 06:13:19

标签: python celery

使用以下总体配置来设置芹菜,这里要注意的是我正在尝试添加更多队列,而这正遇到这个问题。我是celery的新手,所以请忽略错误,并让我知道我是否需要任何详细信息

使用命令:

celery --app=my_app worker -Q a_queue,b_queue,c_queue,d_queue,e_queue,f_queue,g_queue,h_queue,i_queue,j_queue,k_queue,l_queue,m_queue,n_queue,o_queue,p_queue,q_queue,r_queue,s_queue --loglevel=INFO -Ofair

BROKER_URL = f'redis://{REDIS_CONFIGURATION}:6379/{DB_SETTINGS}'

app.conf.task_routes = ([
    # SABRE queues
    ('x.a', {'queue': 'a_queue'}),
    ('x.b', {'queue': 'b_queue'}),
    ('x.c', {'queue': 'c_queue'}),

    ('xa.a', {'queue': 'd_queue'}),
    ('xb.b', {'queue': 'e_queue'}),
    ('xb.c', {'queue': 'f_queue'}),

    ('xc.a', {'queue': 'g_queue'}),
    ('xd.b', {'queue': 'h_queue'}),
    ('xe.c', {'queue': 'i_queue'}),

    ('xf.a'}, {'queue': 'j_queue'}),
    ('xg.b', {'queue': 'k_queue'}),
    ('xh.c', {'queue': 'l_queue'}),

    ('xi.a', {'queue': 'm_queue'}
    ('xj.b', {'queue': 'n_queue'}),
    ('xk.c', {'queue': 'o_queue'}),

    ('xl.a', {'queue': 'p_queue'}),
    ('xm.b', {'queue': 'q_queue'}),
    ('xm.c', {'queue': 'r_queue'}),

    ('providers.custom_tasks.*', {'queue': 's_queue'})
],)

app.conf.broker_url = BROKER_URL

收到以下错误

   File "/usr/local/lib/python3.6/site-packages/celery/worker/worker.py", line 203, in start
     self.blueprint.start(self)
   File "/usr/local/lib/python3.6/site-packages/celery/bootsteps.py", line 119, in start
     step.start(parent)
   File "/usr/local/lib/python3.6/site-packages/celery/bootsteps.py", line 370, in start
     return self.obj.start()
   File "/usr/local/lib/python3.6/site-packages/celery/worker/consumer/consumer.py", line 318, in start
     blueprint.start(self)
   File "/usr/local/lib/python3.6/site-packages/celery/bootsteps.py", line 119, in start
     step.start(parent)
   File "/usr/local/lib/python3.6/site-packages/celery/worker/consumer/tasks.py", line 37, in start
     c.connection, on_decode_error=c.on_decode_error,
   File "/usr/local/lib/python3.6/site-packages/celery/app/amqp.py", line 302, in TaskConsumer
     **kw
   File "/usr/local/lib/python3.6/site-packages/kombu/messaging.py", line 386, in __init__
     self.revive(self.channel)
   File "/usr/local/lib/python3.6/site-packages/kombu/messaging.py", line 407, in revive
     self.declare()
   File "/usr/local/lib/python3.6/site-packages/kombu/messaging.py", line 420, in declare
     queue.declare()
   File "/usr/local/lib/python3.6/site-packages/kombu/entity.py", line 604, in declare
     self._create_exchange(nowait=nowait, channel=channel)
   File "/usr/local/lib/python3.6/site-packages/kombu/entity.py", line 611, in _create_exchange
     self.exchange.declare(nowait=nowait, channel=channel)
   File "/usr/local/lib/python3.6/site-packages/kombu/entity.py", line 182, in declare
     return (channel or self.channel).exchange_declare(
   File "/usr/local/lib/python3.6/site-packages/kombu/abstract.py", line 119, in channel
     type(self).__name__))
kombu.exceptions.NotBoundError: Can't call method on Exchange not bound to a channel

使用REDIS作为经纪人并收到交换错误。

1 个答案:

答案 0 :(得分:1)

这可能与海带中此已知的issue有关。如果您使用的是旧版本,请尝试将kombu更新到4.1.0或更高版本,此问题可能会消失。