unhashable type: 'Redis'
See original GitHub issueVersion:
django-redis==4.10.0
redis==3.3.11
celery==4.4.0
Platform: Python 3.7.4 on Calculate Linux 18.12
Description: If i use Redis as rpc for Celery, i have problem with method __equal__
in Redis class.
[2020-01-31 14:46:05,659: CRITICAL/MainProcess] Unrecoverable error: TypeError("unhashable type: 'Redis'")
Traceback (most recent call last):
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/worker/worker.py", line 205, in start
self.blueprint.start(self)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/bootsteps.py", line 369, in start
return self.obj.start()
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/worker/consumer/consumer.py", line 318, in start
blueprint.start(self)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/worker/consumer/mingle.py", line 40, in start
self.sync(c)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/worker/consumer/mingle.py", line 44, in sync
replies = self.send_hello(c)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/worker/consumer/mingle.py", line 57, in send_hello
replies = inspect.hello(c.hostname, our_revoked._data) or {}
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/app/control.py", line 154, in hello
return self._request('hello', from_node=from_node, revoked=revoked)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/app/control.py", line 106, in _request
pattern=self.pattern, matcher=self.matcher,
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/celery/app/control.py", line 477, in broadcast
limit, callback, channel=channel,
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/kombu/pidbox.py", line 347, in _broadcast
channel=chan)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/kombu/pidbox.py", line 386, in _collect
self.connection.drain_events(timeout=timeout)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/kombu/connection.py", line 315, in drain_events
return self.transport.drain_events(self.connection, **kwargs)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/kombu/transport/virtual/base.py", line 963, in drain_events
get(self._deliver, timeout=timeout)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/kombu/transport/redis.py", line 366, in get
self._register_BRPOP(channel)
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/kombu/transport/redis.py", line 311, in _register_BRPOP
if not self._client_registered(channel, channel.client, 'BRPOP'):
File "/home/psayker/PycharmProjects/ee/py37/lib/python3.7/site-packages/kombu/transport/redis.py", line 306, in _client_registered
(channel, client, cmd) in self._chan_to_sock)
TypeError: unhashable type: 'Redis'
This possibly because in Kombu we use __equal__
method of Redis
class. In Redis
3.3.11, all work fine.
https://github.com/celery/kombu/blob/master/kombu/transport/redis.py#L306
https://github.com/andymccurdy/redis-py/blob/master/redis/client.py#L749
Issue Analytics
- State:
- Created 4 years ago
- Reactions:17
- Comments:5
Top Results From Across the Web
TypeError: unhashable type: 'Redis' #1153 - celery/kombu
I am using Celery with Django and Redis. I am on Mac, using Python 3.7 and redis server is installed (I tested using...
Read more >celery start causes TypeError("unhashable type: 'list'",)
I have checked make_celery's line and backend and broker are strings with the correct data. celery = Celery(app.import_name, backend=app.config[ ...
Read more >celery启动时报错TypeError: unhashable type: 'Redis'
后面的-i部分是国内源,因为国外源太慢了还会出现timeout等问题,所以临时换下源。 跟新完celery之后发现还是这个问题,于是接着 ...
Read more >Change history — Kombu 5.2.4 documentation - Celery
Set redelivered property for Celery with Redis (#1484). ... Fix: check redis response type. ... Timer: Fixed “unhashable type” error on Python 3....
Read more >TypeError: unhashable type: 'list' when ... - Google Groups
I'm trying to make celery work on my project, but when I'm calling a task with delay or apply_async (when I call x(3,9)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After some research I noticed that Redis class has
__eq__
implemented but not__hash__
. From the python docs(https://docs.python.org/3/reference/datamodel.html#object.__hash__)It worked before because models have
__hash__
and__eq__
methods by default.The latest release of redis-py (v3.4.1) fixes this.