Exception raised when publishing from a pubsub object · Issue #151 · redis/redis-py (original) (raw)
pip freeze | grep redis
redis==2.4.5
This code works correctly:
import redis
r = redis.Redis(password='yomama')
r.publish('foo','bar')
This code fails, although the message is correctly published before the code raises an exception:
import redis
r = redis.Redis(password='yomama')
ps = r.pubsub()
ps.publish('foo','bar')
Traceback (most recent call last):
File "./test2", line 6, in
ps.publish('foo','bar')
File "/Users/nfarring/.virtualenvs/mordia/lib/python2.7/site-packages/redis/client.py", line 1136, in publish
return self.execute_command('PUBLISH', channel, message)
File "/Users/nfarring/.virtualenvs/mordia/lib/python2.7/site-packages/redis/client.py", line 1063, in execute_command
return self.parse_response()
File "/Users/nfarring/.virtualenvs/mordia/lib/python2.7/site-packages/redis/client.py", line 1078, in parse_response
if response[0] in self.subscribe_commands:
TypeError: 'long' object is not subscriptable
Here is the same output using ipython:
TypeError Traceback (most recent call last)
/Users/nfarring/ in ()
/Users/nfarring/.virtualenvs/mordia/lib/python2.7/site-packages/redis/client.pyc in publish(self, channel, message)
1134 Returns the number of subscribers the message was delivered to.
1135 """
-> 1136 return self.execute_command('PUBLISH', channel, message)
1137
1138 def listen(self):
/Users/nfarring/.virtualenvs/mordia/lib/python2.7/site-packages/redis/client.pyc in execute_command(self, _args, *_kwargs)
1061 try:
1062 connection.send_command(*args)
-> 1063 return self.parse_response()
1064 except ConnectionError:
1065 connection.disconnect()
/Users/nfarring/.virtualenvs/mordia/lib/python2.7/site-packages/redis/client.pyc in parse_response(self)
1076 "Parse the response from a publish/subscribe command"
1077 response = self.connection.read_response()
-> 1078 if response[0] in self.subscribe_commands:
1079 self.subscription_count = response[2]
1080 # if we've just unsubscribed from the remaining channels,
TypeError: 'long' object is not subscriptable