Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery 4.0.0: No such transport: django

I followed the "First steps with Django" tutorial for Celery 4.0.0: http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

This all works as expected. However, if I then try to change the transport from AMQP to the Django ORM by adding this to the end of settings.py:

CELERY_BROKER_URL = 'django://'

Then when I run the worker process (celery -A proj worker), I get an error:

Traceback (most recent call last):
  File "/home/ac/src/proj/.pyenv/bin/celery", line 11, in <module>
    sys.exit(main())
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/__main__.py", line 14, in main
    _main()
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 326, in main
    cmd.execute_from_commandline(argv)
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 488, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 278, in execute_from_commandline
    return self.handle_argv(self.prog_name, argv[1:])
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 480, in handle_argv
    return self.execute(command, argv)
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 412, in execute
    ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/bin/worker.py", line 221, in run_from_argv
    return self(*args, **options)
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 241, in __call__
    ret = self.run(*args, **kwargs)
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/bin/worker.py", line 255, in run
    **kwargs)
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/worker/worker.py", line 99, in __init__
    self.setup_instance(**self.prepare_args(**kwargs))
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/worker/worker.py", line 120, in setup_instance
    self._conninfo = self.app.connection_for_read()
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/app/base.py", line 732, in connection_for_read
    return self._connection(url or self.conf.broker_read_url, **kwargs)
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/celery/app/base.py", line 808, in _connection
    'broker_connection_timeout', connect_timeout
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/kombu/connection.py", line 179, in __init__
    if not get_transport_cls(transport).can_parse_url:
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/kombu/transport/__init__.py", line 81, in get_transport_cls
    _transport_cache[transport] = resolve_transport(transport)
  File "/home/ac/src/proj/.pyenv/local/lib/python2.7/site-packages/kombu/transport/__init__.py", line 62, in resolve_transport
    raise KeyError('No such transport: {0}'.format(transport))
KeyError: u'No such transport: django'

What am I doing wrong?

like image 373
aco Avatar asked Dec 23 '22 22:12

aco


2 Answers

You can use it as a results backend, but not as a broker anymore.

The list of supported brokers is here, on the celery project site.

From the tutorial page you're following, you have the option of using the django ORM as a results backend:

Extensions django-celery-results - Using the Django ORM/Cache as a result backend

The django-celery-results extension provides result backends using either the Django ORM, or the Django Cache framework.

The full instructions on how to do that are located at this point on the page..

Short answer - Django ORM isn't a broker anymore, it was removed in version 4.0.

like image 132
Withnail Avatar answered Jan 06 '23 07:01

Withnail


There is no a transport called django so you can not use django://. What you may use instead is RabbitMQ like this:

CELERY_BROKER_URL = 'amqp://guest:guest@localhost:5672//'
like image 32
ettanany Avatar answered Jan 06 '23 07:01

ettanany