Celery: AttributeError: 'float' object has no attribute 'items'

Created on 15 Nov 2018  ·  16Comments  ·  Source: celery/celery

on running celery -A proj worker throws this error

[2018-11-15 12:02:53,607: CRITICAL/MainProcess] Unrecoverable error: AttributeError("'float' object has no attribute 'items'",)
Traceback (most recent call last):
File "/user/lib/python3.6/site-packages/celery/worker/worker.py", line 205, in start
self.blueprint.start(self)
File "/user/lib/python3.6/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/user/lib/python3.6/site-packages/celery/bootsteps.py", line 369, in start
return self.obj.start()
File "/user/lib/python3.6/site-packages/celery/worker/consumer/consumer.py", line 317, in start
blueprint.start(self)
File "/user/lib/python3.6/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/user/lib/python3.6/site-packages/celery/worker/consumer/consumer.py", line 593, in start
c.loop(c.loop_args())
File "/user/lib/python3.6/site-packages/celery/worker/loops.py", line 91, in asynloop
next(loop)
File "/user/lib/python3.6/site-packages/kombu/asynchronous/hub.py", line 354, in create_loop
cb(
cbargs)
File "/user/lib/python3.6/site-packages/kombu/transport/redis.py", line 1040, in on_readable
self.cycle.on_readable(fileno)
File "/user/lib/python3.6/site-packages/kombu/transport/redis.py", line 337, in on_readable
chan.handlerstype
File "/user/lib/python3.6/site-packages/kombu/transport/redis.py", line 724, in _brpop_read
self.connection._deliver(loads(bytes_to_str(item)), dest)
File "/user/lib/python3.6/site-packages/kombu/transport/virtual/base.py", line 983, in _deliver
callback(message)
File "/user/lib/python3.6/site-packages/kombu/transport/virtual/base.py", line 632, in _callback
self.qos.append(message, message.delivery_tag)
File "/user/lib/python3.6/site-packages/kombu/transport/redis.py", line 149, in append
pipe.zadd(self.unacked_index_key, time(), delivery_tag) \
File "/user/lib/python3.6/site-packages/redis/client.py", line 2263, in zadd
for pair in iteritems(mapping):
File "/user/lib/python3.6/site-packages/redis/_compat.py", line 123, in iteritems
return iter(x.items())
AttributeError: 'float' object has no attribute 'items'

Using Python 3.6.6, redis 3.0.0.post1

Most helpful comment

Not a celery issue - Seems to be an issue with Redis 3.0.0.post1 installed via pip.

Solution: Roll back redis with pip: pip install redis==2.10.6

everything working again for me.

All 16 comments

I'm getting a very similar error this morning:

[2018-11-15 09:55:33,342: CRITICAL/MainProcess] Unrecoverable error: AttributeError("'float' object has no attribute 'iteritems'",)
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/celery/worker/worker.py", line 205, in start
    self.blueprint.start(self)
  File "/usr/local/lib/python2.7/dist-packages/celery/bootsteps.py", line 119, in start
    step.start(parent)
  File "/usr/local/lib/python2.7/dist-packages/celery/bootsteps.py", line 369, in start
    return self.obj.start()
  File "/usr/local/lib/python2.7/dist-packages/celery/worker/consumer/consumer.py", line 317, in start
    blueprint.start(self)
  File "/usr/local/lib/python2.7/dist-packages/celery/bootsteps.py", line 119, in start
    step.start(parent)
  File "/usr/local/lib/python2.7/dist-packages/celery/worker/consumer/consumer.py", line 593, in start
    c.loop(*c.loop_args())
  File "/usr/local/lib/python2.7/dist-packages/celery/worker/loops.py", line 91, in asynloop
    next(loop)
  File "/usr/local/lib/python2.7/dist-packages/kombu/asynchronous/hub.py", line 354, in create_loop
    cb(*cbargs)
  File "/usr/local/lib/python2.7/dist-packages/kombu/transport/redis.py", line 1040, in on_readable
    self.cycle.on_readable(fileno)
  File "/usr/local/lib/python2.7/dist-packages/kombu/transport/redis.py", line 337, in on_readable
    chan.handlers[type]()
  File "/usr/local/lib/python2.7/dist-packages/kombu/transport/redis.py", line 724, in _brpop_read
    self.connection._deliver(loads(bytes_to_str(item)), dest)
  File "/usr/local/lib/python2.7/dist-packages/kombu/transport/virtual/base.py", line 983, in _deliver
    callback(message)
  File "/usr/local/lib/python2.7/dist-packages/kombu/transport/virtual/base.py", line 632, in _callback
    self.qos.append(message, message.delivery_tag)
  File "/usr/local/lib/python2.7/dist-packages/kombu/transport/redis.py", line 149, in append
    pipe.zadd(self.unacked_index_key, time(), delivery_tag) \
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 2263, in zadd
    for pair in iteritems(mapping):
  File "/usr/local/lib/python2.7/dist-packages/redis/_compat.py", line 94, in iteritems
    return x.iteritems()
AttributeError: 'float' object has no attribute 'iteritems'

Python 2.7, Redis 3.0.0.post1

Not a celery issue - Seems to be an issue with Redis 3.0.0.post1 installed via pip.

Solution: Roll back redis with pip: pip install redis==2.10.6

everything working again for me.

Dependency pinning is a celery issue. Looks to be fixed here though
https://github.com/celery/celery/pull/5176

Can we quick release 4.2.2 to solve this please?

You can pin the dependency outside of Celery until this is fixed.

Pipenv users: add redis = "~=2.10.6" _before_ the celery entry in the Pipfile.

it's fixed in kombu and celery master

Can we get a patch release for celery?

Not a celery issue - Seems to be an issue with Redis 3.0.0.post1 installed via pip.

Solution: Roll back redis with pip: pip install redis==2.10.6

everything working again for me.

thanks

Can we get a patch release for celery?

A patch release would be great!!!

Is there something the community can do to make it possible sooner rather than later? As you can see, many related projects are referring to this issue and pinning down the redis version.

I did release a patch for kombu. It should resolve the issue.
Please subscribe for release notifications on our repositories instead of pinging us.

Not a celery issue - Seems to be an issue with Redis 3.0.0.post1 installed via pip.

Solution: Roll back redis with pip: pip install redis==2.10.6

everything working again for me.

Worked thank you !!

It should be fixed in newest update: Celery 4.3.0 (kobu 4.5.0).
You don't need to rollback redis version.

It should be fixed in newest update: Celery 4.3.0 (kobu 4.5.0).
You don't need to rollback redis version.

True, this works in my case.

Hi,
I am getting issue AttributeError: 'float' object has no attribute 'item'
while executing call back function callbacks = [checkpointer, earlystopper, lr_reducer, TensorBoardColabCallback(tbc)]
which call /usr/local/lib/python3.6/dist-packages/tensorboardcolab/callbacks.py
I have install install redis==2.10.6 still issue persist.
I am using google colab.

@dhanashri88 - I don't think this is a Celery issue. Your issue report/tracceback is not complete, but it looks like this is a tensorboard issue. Please ask their support channel/mailing list/github issues for help.

Was this page helpful?
0 / 5 - 0 ratings