Celery Error 'No such transport: amqp'

2019-07-01 15:09发布

问题:

Celery was working fine, one day the command-line worker failed to start up with the following trace:

Traceback (most recent call last):
  File "/home/buildslave/venv/bin/celery", line 9, in <module>
    load_entry_point('celery==3.0.7', 'console_scripts', 'celery')()
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/__main__.py", line 14, in main
    main()
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 942, in main
    cmd.execute_from_commandline(argv)
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 886, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/bin/base.py", line 175, in execute_from_commandline
    return self.handle_argv(prog_name, argv[1:])
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 881, in handle_argv
    return self.execute(command, argv)
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 856, in execute
    return cls(app=self.app).run_from_argv(self.prog_name, argv)
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 142, in run_from_argv
    return self(*args, **options)
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 112, in __call__
    ret = self.run(*args, **kwargs)
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 214, in run
    return self.target.run(*args, **kwargs)
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/bin/celeryd.py", line 153, in run
    return self.app.Worker(**kwargs).run()
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/apps/worker.py", line 167, in run
    print(str(self.colored.cyan(' \n', self.startup_info())) +
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/celery/apps/worker.py", line 234, in startup_info
    'conninfo': self.app.connection().as_uri(),
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/kombu/connection.py", line 445, in as_uri
    fields = self.info()
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/kombu/connection.py", line 434, in info
    return OrderedDict(self._info())
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/kombu/connection.py", line 413, in _info
    D = self.transport.default_connection_params
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/kombu/connection.py", line 636, in transport
    self._transport = self.create_transport()
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/kombu/connection.py", line 395, in create_transport
    return self.get_transport_cls()(client=self)
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/kombu/connection.py", line 402, in get_transport_cls
    transport_cls = get_transport_cls(transport_cls)
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/kombu/transport/__init__.py", line 110, in get_transport_cls
    _transport_cache[transport] = _get_transport_cls(transport)
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/kombu/transport/__init__.py", line 92, in _get_transport_cls
    transport_module_name, transport_cls_name = resolve_transport(transport)
  File "/home/buildslave/venv/local/lib/python2.7/site-packages/kombu/transport/__init__.py", line 87, in resolve_transport
    raise KeyError('No such transport: %s' % (transport, ))
KeyError: 'No such transport: amqp'

Tracing through the code showed 'amqp' mysteriously missing from kombu.transport.TRANSPORT_ALIASES -- but that's where I lost the trail.

回答1:

The problem appears to be due to an upgrade to celery 3.0.7. The following resolved the issue for me:

pip install kombu==2.4.0

Note: this appears to have been resolved by kombu==2.4.3 per https://github.com/celery/kombu/commit/c3b7a0d885fef3a43b76af0881fee6b5d012923f