-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
PubSubWorkerThread.run
loops on a call to get_message
. If the connection is lost, this call will silently attempt reconnection. However, if a single reconnect attempt fails, then an exception will bubble up. Since there is nobody to catch the exception, the thread dies.
An easy way to reproduce the issue is to set up a subscription and then restart the Redis server. On my machine, Redis takes a few seconds to restart. redis-py will attempt to reconnect faster than this and get a connection refused error. I would have expected redis-py to simply eventually reconnect after the Redis server comes back up.
I believe what is needed here is a way for the PubSubWorkerThread to reconnect multiple times until success. Putting a try/except around the call to get_message
does the trick, but I don't know if that's the right answer.