当运行示例芹菜任务时,我遇到了一个' TypeError:必须是str或None,而不是字节'错误

时间:2017-07-14 20:27:14

标签: python celery

控制台输出:

    [2017-07-14 16:17:30,026: CRITICAL/MainProcess] Unrecoverable error: TypeError('must be str or None, not bytes',)

Traceback (most recent call last):
  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/celery/worker/worker.py", line 203, in start
    self.blueprint.start(self)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/celery/bootsteps.py", line 119, in start
    step.start(parent)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/celery/bootsteps.py", line 370, in start
    return self.obj.start()

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/celery/worker/consumer/consumer.py", line 318, in start
    blueprint.start(self)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/celery/bootsteps.py", line 119, in start
    step.start(parent)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/celery/worker/consumer/connection.py", line 21, in start
    c.connection = c.connect()

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/celery/worker/consumer/consumer.py", line 405, in connect
    conn = self.connection_for_read(heartbeat=self.amqheartbeat)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/celery/worker/consumer/consumer.py", line 412, in connection_for_read
    self.app.connection_for_read(heartbeat=heartbeat))

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/celery/worker/consumer/consumer.py", line 436, in ensure_connected
    callback=maybe_shutdown,

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/kombu/connection.py", line 405, in ensure_connection
    callback)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/kombu/utils/functional.py", line 333, in retry_over_time
    return fun(*args, **kwargs)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/kombu/connection.py", line 261, in connect
    return self.connection

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/kombu/connection.py", line 802, in connection
    self._connection = self._establish_connection()

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/kombu/connection.py", line 757, in _establish_connection
    conn = self.transport.establish_connection()

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/kombu/transport/pyamqp.py", line 130, in establish_connection
    conn.connect()

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/amqp/connection.py", line 302, in connect
    self.drain_events(timeout=self.connect_timeout)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/amqp/connection.py", line 483, in drain_events
    while not self.blocking_read(timeout):

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/amqp/connection.py", line 489, in blocking_read
    return self.on_inbound_frame(frame)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/amqp/method_framing.py", line 69, in on_frame
    callback(channel, method_sig, buf, None)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/amqp/connection.py", line 493, in on_inbound_method
    method_sig, payload, content,

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/amqp/abstract_channel.py", line 142, in dispatch_method
    listener(*args)

  File "/Users/mainUser/anaconda/lib/python3.6/site-packages/amqp/connection.py", line 347, in _on_start
    self.mechanisms = mechanisms.split(b' ')
TypeError: must be str or None, not bytes

Python代码:

 from celery import Celery
 app = Celery('tasks', broker='amqp://guest:guest@localhost:5672//')
 @app.task
 def add(x, y):
     return(x + y)

RabbitMQ服务器已启动并正在运行。

0 个答案:

没有答案