I've got an issue that occurs when attempting to subscribe to a channel when a Redis server is down. To reproduce, assuming the Redis server is down:
cli = redis.Redis(host='localhost')
ps = cli.pubsub()
Problem is here:
def execute_command(self, *args, **kwargs):
"Execute a publish/subscribe command"
if self.connection is None:
self.connection = self.connection_pool.get_connection(
connection = self.connection
# resubscribe to all channels and patterns before
# resending the current command
for channel in self.channels:
for pattern in self.patterns:
Basically, if we're trying to subscribe here, we'll get a ConnectionError, disconnect and then try to re-subscribe to the channel, which starts a recursive loop. I suggest that if we detect that the command we're trying to send here is 'SUBSCRIBE' or 'PSUBSCRIBE' then we don't attempt to resubscribe to any channels, and instead just raise the exception.
if args in ('SUBSCRIBE', 'PSUBSCRIBE'):
I have a fix for it, check it out here:
Awesome, can't wait for it to be included!
manually reconnect the connection in the PubSub class. This avoids bl…
…owing out the stack. Fixes #179 and #195.
back-port part of 32256bb
Original commit log:
manually reconnect the connection in the PubSub class. This avoids blowing out the stack. Fixes #179 and #195.