kombu: AttributeError: 'ChannelPromise' object has no attribute '__value__'

pip freeze:

-e git://github.com/django/django.git@df09d854828bcff56eb72f48ff1ba8fce7e90c90#egg=Django-origin/HEAD
Jinja2==2.7.3
MarkupSafe==0.23
-e git://github.com/python-imaging/Pillow@24cb7bf3df6660bb2bd705b3197e97947dd40a50#egg=Pillow-dev
PyYAML==3.11
Pygments==1.6
Unidecode==0.04.16
-e git://github.com/celery/py-amqp.git@6b945b7065bd3bc53142e2d3f1d520d6f4a3d2de#egg=amqp-origin/master
anyjson==0.3.3
argparse==1.2.1
-e git://github.com/celery/billiard.git@0c8b96c47551f4f0d2d58c53dda7251bcf03236c#egg=billiard-origin/HEAD
bpython==0.12
-e git://github.com/celery/celery.git@2391c30d13c03ba778cdb58208aeb70040fbc9cf#egg=celery-origin/HEAD
chardet==2.0.1
colorama==0.2.5
command-not-found==0.3
-e git://github.com/SimonSapin/cssselect.git@f7b38ba6446d06ba3ed815729e65229532cd1818#egg=cssselect-origin/HEAD
defer==1.0.6
-e git://github.com/django-admin-bootstrapped/django-admin-bootstrapped.git@cbb567b85d0800ec9ed4da07004bde91d2a22e5a#egg=django_admin_bootstrapped-origin/master
-e git://github.com/davidfischer-ch/django-allauth.git@42ccb12701609b2b213e0c1128be374413678ff1#egg=django_allauth-origin/master
django-appconf==0.6
-e git://github.com/brack3t/django-braces.git@c4491e223ba56e22489ac26f4bc17d674eae34f2#egg=django_braces-origin/HEAD
-e git://github.com/davidfischer-ch/django-celery.git@1509614cdccedabb86217ee92677d495dbac1270#egg=django_celery-origin/dev
-e git://github.com/django-compressor/django-compressor.git@67f5de2cf503e2c375e5fe36f050b8dfa8cba145#egg=django_compressor-origin/develop
-e git://github.com/davidfischer-ch/django-crispy-forms.git@568b60cc8073740221f133390b2dd921c442da6b#egg=django_crispy_forms-origin/HEAD
-e git://github.com/morninj/django-email-obfuscator.git@02cee5f7bc0c3798ec2f4e154eb0c9aebcf2ae4f#egg=django_email_obfuscator-origin/master
-e git://github.com/django-extensions/django-extensions.git@f7b1bb51aba9a5b749e6964833b429faf948e74d#egg=django_extensions-dev
-e git://github.com/alex/django-filter.git@d88b98dd2b70551deb9c128b209fcf783b325acc#egg=django_filter-develop
-e git://github.com/evonove/django-oauth-toolkit.git@324cd9cd22833a038306f462a00f912b062f4519#egg=django_oauth_toolkit-origin/HEAD
django-phonenumber-field==0.5
-e git://github.com/davidfischer-ch/django-sendfile.git@7f79b124c6153a200116906a72110069f0eac268#egg=django_sendfile-dev
-e git://github.com/mbi/django-simple-captcha.git@47260b8b4c416bc5c5781e1724103d0c9c1cb4f6#egg=django_simple_captcha-origin/master
-e git://github.com/davidfischer-ch/django-rest-framework.git@b2e07d8613c289e14b2054e1e76837c29807595e#egg=djangorestframework-namespace
html5lib==0.999
-e git://github.com/celery/kombu.git@244b882e0c103b915e98de6ebb7d0cb026974515#egg=kombu-origin/HEAD
language-selector==0.1
lxml==3.3.5
mock==1.0.1
oauthlib==0.6.1
passlib==1.6.2
phonenumbers==6.1.0
psycopg2==2.5.3
pyaml==14.05.7
pycallgraph==1.0.1
pycurl==7.19.3
pygal==1.4.6
pygobject==3.12.0
pymongo==2.7.1
python-apt==0.9.3.5
python3-openid==3.0.4
pytoolbox==8.3.3-beta
pytz==2014.4
requests==2.2.1
requests-oauthlib==0.4.1
selenium==2.41.0
sendgrid==0.5.1
-e git://github.com/elbuo8/sendgrid-django.git@b026123f6dac27de9f67b95c2c9ef172bda53c2a#egg=sendgrid_django-origin/master
six==1.5.2
slumber==0.7.1.dev
smtpapi==0.1.2
-e git://github.com/davidfischer-ch/splinter.git@3d4924e1ac48b3e8968050246b0e77711f3f635c#egg=splinter-origin/HEAD
uWSGI==2.0.5.1
ufw==0.34-rc-0ubuntu2
unattended-upgrades==0.1
unittest2py3k==0.5.1
urllib3==1.7.1
-e git://github.com/alecthomas/voluptuous.git@0873a4d1f542997fcb6849fdfc0f68d66d7b7f18#egg=voluptuous-dev

Traceback:

Traceback (most recent call last):
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/utils/__init__.py", line 405, in __call__
    return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/cloudncode/venv/src/django/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django-braces/braces/views/_access.py", line 66, in dispatch
    request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/base.py", line 87, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 205, in post
    return super(BaseCreateView, self).post(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 171, in post
    return self.form_valid(form)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 147, in form_valid
    self.object = form.save()
  File "/home/ubuntu/cloudncode/server/cloudncode_base/forms/encoding.py", line 42, in save
    instance.launch()
  File "/home/ubuntu/cloudncode/server/cloudncode_base/models/encoding.py", line 89, in launch
    tasks.EncodingTask().apply_async(kwargs={'task_pk': self.pk}, task_id=self.meta_id)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/task.py", line 462, in apply_async
    **dict(self._get_exec_options(), **options)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/base.py", line 383, in send_task
    amqp.send_task_message(P, name, message, **options)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/amqp.py", line 468, in publish_task
    **properties
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 168, in publish
    routing_key, mandatory, immediate, exchange, declare)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 436, in _ensured
    return fun(*args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 173, in _publish
    channel = self.channel
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 190, in _get_channel
    channel = self._channel = channel()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/utils/__init__.py", line 407, in __call__
    value = self.__value__ = self.__contract__()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 205, in <lambda>
    channel = ChannelPromise(lambda: connection.default_channel)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 756, in default_channel
    self.connection
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 741, in connection
    self._connection = self._establish_connection()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 696, in _establish_connection
    conn = self.transport.establish_connection()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/transport/pyamqp.py", line 112, in establish_connection
    conn = self.Connection(**opts)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 217, in __init__
    self.connect()
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 236, in connect
    self.drain_events()
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 354, in drain_events
    return self.blocking_read(timeout)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 359, in blocking_read
    return self.on_inbound_frame(read_frame())
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/method_framing.py", line 65, in frame_handler
    callback(channel, method_sig, buf, None)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 385, in on_inbound_method
    method_sig, payload, content,
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/abstract_channel.py", line 124, in dispatch_method
    args, _ = loads(amqp_method.args, payload, 4)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/serialization.py", line 229, in loads
    val[key], offset = _read_item(buf, offset)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/serialization.py", line 154, in _read_item
    ftype, type(ftype)))
amqp.exceptions.FrameSyntaxError: Unknown value in table: 70 (<class 'int'>)
ERROR Internal Server Error: /fr/encoding/task/create
Traceback (most recent call last):
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/utils/__init__.py", line 405, in __call__
    return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/cloudncode/venv/src/django/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django-braces/braces/views/_access.py", line 66, in dispatch
    request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/base.py", line 87, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 205, in post
    return super(BaseCreateView, self).post(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 171, in post
    return self.form_valid(form)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 147, in form_valid
    self.object = form.save()
  File "/home/ubuntu/cloudncode/server/cloudncode_base/forms/encoding.py", line 42, in save
    instance.launch()
  File "/home/ubuntu/cloudncode/server/cloudncode_base/models/encoding.py", line 89, in launch
    tasks.EncodingTask().apply_async(kwargs={'task_pk': self.pk}, task_id=self.meta_id)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/task.py", line 462, in apply_async
    **dict(self._get_exec_options(), **options)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/base.py", line 383, in send_task
    amqp.send_task_message(P, name, message, **options)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/amqp.py", line 468, in publish_task
    **properties
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 168, in publish
    routing_key, mandatory, immediate, exchange, declare)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 436, in _ensured
    return fun(*args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 173, in _publish
    channel = self.channel
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 190, in _get_channel
    channel = self._channel = channel()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/utils/__init__.py", line 407, in __call__
    value = self.__value__ = self.__contract__()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 205, in <lambda>
    channel = ChannelPromise(lambda: connection.default_channel)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 756, in default_channel
    self.connection
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 741, in connection
    self._connection = self._establish_connection()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 696, in _establish_connection
    conn = self.transport.establish_connection()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/transport/pyamqp.py", line 112, in establish_connection
    conn = self.Connection(**opts)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 217, in __init__
    self.connect()
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 236, in connect
    self.drain_events()
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 354, in drain_events
    return self.blocking_read(timeout)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 359, in blocking_read
    return self.on_inbound_frame(read_frame())
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/method_framing.py", line 65, in frame_handler
    callback(channel, method_sig, buf, None)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 385, in on_inbound_method
    method_sig, payload, content,
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/abstract_channel.py", line 124, in dispatch_method
    args, _ = loads(amqp_method.args, payload, 4)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/serialization.py", line 229, in loads
    val[key], offset = _read_item(buf, offset)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/serialization.py", line 154, in _read_item
    ftype, type(ftype)))
amqp.exceptions.FrameSyntaxError: Unknown value in table: 70 (<class 'int'>)

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 5
  • Comments: 35 (7 by maintainers)

Most upvoted comments

@fwachs Hello ! I’m getting the error too. It seems that it does not even try to connect and crashs before. Did you find any workaround ? Thanks.

i’m still getting this error.

celery==5.2.3
kombu==5.2.3

Anyone can help?

@tmehlinger you saved my day thanks! I now import the app object directly from MY celery.py that actually reads up the project’s settings.py

For those who tried all the above solution but still getting the same error (espeically if you are using docker-compose). Maybe this will help you:

Check your environment variable setting for CELERY_BROKER_URL, for both the container of django and celery.

So the stupid mistake I made was that I only set this environment variable for the django container and forgot setting the one for the celery container in my docker-compose.yml file. I was testing by setting it directly with the environment: field for the django service, then I decided to move it to a seperate .env file and reference it with env_file: .env for both django and celery services, which then solved the issue. What a silly mistake…

In my case, mq was not running. After I execute it, the error message doesn’t occur any more.

I actually tracked it down to not setting the AMQP host correctly when configuring Celery. I inherited a Django app with some code that looks something like this:

app = Celery('app_name', broker='amqp://')
class config:
    BROKER_URL = 'amqp://a_real_host:5672/'
app.config_from_object(config)

The broker URL from config wasn’t overriding what was passed in to Celery (not sure whether this is desired behavior but it seems fine to me). Whenever some code would try to invoke a task, it would fail trying to connect to localhost.

To be clear–it was most certainly a problem in my own code, which I’ve since fixed. Hopefully this will help someone else.

it work well for me kombu==5.1.0 celery==5.1.2

but work badly for me kombu==5.3.2 celery==5.1.2

In case any of you is having problem running this on a CI/CD pipeline with Python, I solved this by adding RabbitMQ as a service in my .yml file:

  services:
      - rabbitmq:latest
  variables:
    RABBITMQ_DEFAULT_USER: guest
    RABBITMQ_DEFAULT_PASS: guest
    AMQP_URL: 'amqp://guest:guest@rabbitmq:5672'

Hope this helps.

@zhao-weiqi What helped me to resolve this on Mac was: brew install rabbitmq brew services start rabbitmq

For me, reinstalled rabbitmq with newer version and it worked.

In my case the problem was a container that was down

I run into this error when the broker is not yet online. I am running a worker, a master, and a rabbitmq broker in separate containers with docker-compose. If I put a sleep before the first time I call celery_instance.send_task in the master (basically waiting until the broker has fully started), then it connects fine. However if I take out the sleep, so that I begin trying to connect while the broker is still turning on, and the broker port has not been bound yet, then I see a similar stacktrace. Is the celery instance not being initialized correctly in the master, as dpetzold indicates? Because adding only a sleep of ~10 seconds before the call to send_task without changing any configuration or code makes it work, which makes me believe that I am configuring celery for my connection correctly.

In this case I would really like to inherit the default retry logic that my worker celery process seems to have:

http_worker_1 | [2016-08-14 20:49:57,786: ERROR/MainProcess] consumer: Cannot connect to amqp://myusername:**@rabbitmq:5672//: [Errno 111] Connection refused.
http_worker_1 | Trying again in 6.00 seconds...
http_worker_1 | 

I am running on alpine:3.4 Python 3.5.1 amqp==1.4.9 anyjson==0.3.3 billiard==3.3.0.23 celery==3.1.23 kombu==3.0.35 pytz==2016.6.1 requests==2.11.0

Any news on this? I’m getting the same error. How should we procede?