diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2019-03-18 12:59:37 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2019-03-18 12:59:37 -0700 |
commit | c26e7c545f0b6205465394908ae18a248b79cc86 (patch) | |
tree | cc1a996c0806bf323fc5573ad5f39f5c9fbacffe | |
parent | 8697007c6352f2b27fe303c31418e948f217db38 (diff) | |
download | redis-py-c26e7c545f0b6205465394908ae18a248b79cc86.tar.gz |
make sure the selector is instantiated prior to cleaning it up
-rw-r--r-- | CHANGES | 2 | ||||
-rwxr-xr-x | redis/connection.py | 6 |
2 files changed, 6 insertions, 2 deletions
@@ -1,3 +1,5 @@ +* 3.2.2 (in development) + * Cleanup the Connection's selector correctly. Thanks Bruce Merry. #1153 * 3.2.1 * Fix SentinelConnectionPool to work in multiprocess/forked environments. * 3.2.0 diff --git a/redis/connection.py b/redis/connection.py index 851690f..d620e27 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -460,6 +460,7 @@ class Connection(object): self.retry_on_timeout = retry_on_timeout self.encoder = Encoder(encoding, encoding_errors, decode_responses) self._sock = None + self._selector = None self._parser = parser_class(socket_read_size=socket_read_size) self._description_args = { 'host': self.host, @@ -581,8 +582,9 @@ class Connection(object): self._parser.on_disconnect() if self._sock is None: return - self._selector.close() - self._selector = None + if self._selector is not None: + self._selector.close() + self._selector = None try: if os.getpid() == self.pid: self._sock.shutdown(socket.SHUT_RDWR) |