summaryrefslogtreecommitdiff
path: root/redis/connection.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2019-03-18 12:59:37 -0700
committerAndy McCurdy <andy@andymccurdy.com>2019-03-18 12:59:37 -0700
commitc26e7c545f0b6205465394908ae18a248b79cc86 (patch)
treecc1a996c0806bf323fc5573ad5f39f5c9fbacffe /redis/connection.py
parent8697007c6352f2b27fe303c31418e948f217db38 (diff)
downloadredis-py-c26e7c545f0b6205465394908ae18a248b79cc86.tar.gz
make sure the selector is instantiated prior to cleaning it up
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-xredis/connection.py6
1 files changed, 4 insertions, 2 deletions
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)