Grokzen / redis-py-cluster

Python cluster client for the official redis cluster. Redis 3.0+.
https://redis-py-cluster.readthedocs.io/
MIT License
1.1k stars 315 forks source link

ConnectionError not handled correctly if there are no connections in the pool #453

Closed FranGM closed 3 years ago

FranGM commented 3 years ago

Hi there!

Recently we ran into an issue where it seems like we were not handling a ConnectionError correctly and tried to call connection.disconnect() (see here ) when connection had a None value, which results in an unhandled exception being raised.

Seems like if you're using ClusterBlockingConnectionPool, and time out before a connection is available a ConnectionError will get raised, which gets mishandled in this case. The rest of the error handling seems correct to me, so I'm going to submit a PR that just checks that connection is not None before attempting to disconnect, and I'll be happy to add any other stuff that you think might be missing.

FranGM commented 3 years ago

I don't know if I can reopen issues but there's another instance of this issue with a fix here: https://github.com/Grokzen/redis-py-cluster/pull/472