63

I have RabbitMQ and Celery running locally on my Mac (OS/X 10.13.4), the following code works locally when I run add.delay(x,y):

#!/usr/bin/env python
from celery import Celery
from celery.utils.log import get_task_logger

logger = get_task_logger(__name__)

app = Celery('tasks', \
        broker='pyamqp://appuser:xx@c2/appvhost', \
        backend='db+mysql://appuser:xx@c2/pigpen')

@app.task(bind=True)
def dump_context(self, x, y):
    print('Executing task id {0.id}, args: {0.args!r} kwargs {0.kwargs!r}'.format(self.request))

@app.task
def add(x, y):
    logger.info('Adding {0} + {1}'.format(x, y))
    return x + y

However when I try to run the Celery worker on an ODROID-C2 running Kali 2018.2 (w. current updates, I get the following error when running celery -A tasks worker --loglevel=info:

Traceback (most recent call last):
  File "/usr/local/bin/celery", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/celery/__main__.py", line 14, in main
    _main()
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 326, in main
    cmd.execute_from_commandline(argv)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 488, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/base.py", line 281, in execute_from_commandline
    return self.handle_argv(self.prog_name, argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 480, in handle_argv
    return self.execute(command, argv)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 412, in execute
    ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/worker.py", line 221, in run_from_argv
    return self(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/base.py", line 244, in __call__
    ret = self.run(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/worker.py", line 255, in run
    **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/worker/worker.py", line 99, in __init__
    self.setup_instance(**self.prepare_args(**kwargs))
  File "/usr/local/lib/python2.7/dist-packages/celery/worker/worker.py", line 122, in setup_instance
    self.should_use_eventloop() if use_eventloop is None
  File "/usr/local/lib/python2.7/dist-packages/celery/worker/worker.py", line 241, in should_use_eventloop
    self._conninfo.transport.implements.async and
  File "/home/autossh/.local/lib/python2.7/site-packages/kombu/transport/base.py", line 125, in __getattr__
    raise AttributeError(key)
AttributeError: async

From the Kali ODROID I am able to connect to the RabbitMQ instance on the host named c2 using a Python Pika script and mysql from that device works to the c2 machine as well. I have found similar errors, none of those solutions have worked for me.

Celery version installed on the ODROID-C2 via pip is:

celery --version
4.1.0 (latentcall)
1
  • 3
    Slightly unhappy it seemed to break quite a few peoples prod. There are a few GitHub issues about it as well... Commented May 23, 2018 at 8:21

6 Answers 6

105

We sorted by just updating to celery==4.1.1

it seems the latest release for the 4.1.X sorted out the module name change on kombu

Sign up to request clarification or add additional context in comments.

1 Comment

Please upvote this as this is the correct answer. If you set kombu==4.1.0 and then later upgrade celery, you'll just experience this issue all over again.
27

Make sure you are using Kombu 4.1.0. The latest version of Kombu renames async to asynchronous.

3 Comments

I backed kombu to 4.1.0 on that device just to see if it helped, it didn't.
shouldn't kombu have been upgraded to 5.x?
The correct answer is @shipperizer below. Instead upgrade to celery==4.1.1. If you set kombu==4.1.0 you'll just encounter this issue again when you upgrade celery past 4.1.0.
14

Celery does not pin its requirements for kombu and billiard to specific versions. They require the following:

billiard>=3.5.0.2,<3.6.0
kombu>=4.0.2,<5.0

https://github.com/celery/celery/blob/v4.1.0/requirements/default.txt

kombu 4.2.0 was released with a breaking change and previous versions of celery automatically install it.

Since Celery doesn't pin specific versions, you should pin to the following if you will continue to use celery 4.1.0:

kombu==4.1.0
billiard==3.5.0.2

2 Comments

Should be billiard==3.5.0.2. Pip install will fail with 3.0.5.2.
Thanks, I set my post deploy/fistboot script to install kombu==4.1.0 before installing Celery.
12

pip install --upgrade 'celery>=4.2.0rc4'

kombu==4.2.0 renames async to asynchronous, celery fixed it in celery==4.2.0rc4.

So you should upgrade celery to 4.2.0rc4.

refer: https://github.com/celery/celery/commit/c8ef7ad60b72a194654c58beb04a1d65cd0435ad

1 Comment

4.1.1, which is an official release, fixes it.
6

That was the issue, it was in fact the kombu version.

I managed to get 2 versions of kombu installed, 4.2.0 as the 'appuser' user, which I was trying to start the worker under, and 4.1.0 as 'root'. The 4.1.0 as 'root' would work, the other user did not.

I removed kombu 4.2.0 from the 'appuser' user account (pip uninstall kombu as that user), so it would use the system-wide installed package, and the Celery worker operated correctly under that account.

To verify that it is in fact kombu 4.2.0 that breaks, I removed the system-wide 4.1.0 version and let pip install the latest version, which it gets as 4.2.0, and the Celery worker would no longer start. I uninstalled it and forced pip to install 4.1.0 (pip install kombu==4.1.0) and the worker operated correctly.

As another check I went to my Mac, where I originally wrote/tested this code, and checked the kombu version installed there by pip: 4.1.0. I'm not sure why pip on the Mac and Pi3 installed the 4.1.0 version of kombu while pip on the ODROID-C2 installed the 4.2.0 version. I'll dig more if I get a chance but it works now.

1 Comment

Because kombu 4.2.0 was literally released a few hours before this post. I'm guessing when you installed pip packages w/ root, is was pre-4.2.0 release, and when installing w/ appuser it was post-4.2.0 release, since as @Daniel says, celery doesn't pin the version, so simply installs the latest version that is <5.0.
0

A quick hack fix is to disable the result backend:

# CELERY_RESULT_BACKEND = 'redis://redis'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.