Open luhn opened 3 years ago
This is great code, but I believe we had a discussion before about how this was not the job of redis-py or aioredis. In my personal belief, I agree with this since people may want to be able to have a custom implementation for server failing.
Currently when a connection breaks, get_message()
behaves differently than Redis.publish()
, PubSub.subscribe()
, or whatever your favorite command might be. That's why I'm reporting a bug. It should work exactly the same as everything else.
There's even a whole connect callback that will resubscribe to all subscribe topics upon reconnection, so obviously the implementation is meant to reconnect.
I don't see where publish
has a reconnection option. subscribe
needs reconnection since it's long living, whereas publish (which I didn't see have a reconnect option) and get_message
are single execution commands.
Maybe "reconnect" is the wrong word. All get_message
needs to do is conn.disconnect()
when a ConnectionError
occurs. Connection
will handle the rest.
I'm not sure what publish()
does behind the scenes, but the effect is the same—The next call to publish()
will use a new connection.
FWIW, the equivalent issue+PR I opened with redis-py has been merged. https://github.com/andymccurdy/redis-py/issues/1572
@luhn apologies, I never had a chance to respond, especially after I made sense of "Maybe "reconnect" is the wrong word". Thanks for also linking to redis-py. I'll probably be skipping your PR since I'll be making a huge PR port from redis-py tomorrow.
Thanks for creating the issue though!
Counterpart of https://github.com/andymccurdy/redis-py/issues/1572
Run the following script:
While running, stop the Redis server and then start it again.
Expected behavior:
publish()
andget_message()
will fail while server is stopped, then succeed again after server restarts.Observed behavior:
publish()
resumes working, butget_message()
continues to fail with the following traceback: