diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2014-07-06 19:52:28 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2014-07-06 19:52:28 -0700 |
commit | 83013b5df1ea32213a77f81be08ffb40d56bace6 (patch) | |
tree | 4a8248cd2a33f61666a9c18b2472bd6b58239e0b | |
parent | 310cb1c58c059fc6d007a67edda8166fb4c962e6 (diff) | |
download | redis-py-83013b5df1ea32213a77f81be08ffb40d56bace6.tar.gz |
check for the server closing a connection that's compatible with Python 3
fixes #508
-rw-r--r-- | CHANGES | 2 | ||||
-rwxr-xr-x | redis/connection.py | 4 |
2 files changed, 4 insertions, 2 deletions
@@ -13,6 +13,8 @@ either to StrictRedis.__init__ or from_url will still work but will also emit a DeprecationWarning. Instead use the "encoding" and "encoding_errors" options. + * Fixed a compatability bug with Python 3 when sockets the server closes + a connection. * 2.10.1 * Fixed a bug where Sentinel connections to a server that's no longer a master and receives a READONLY error will disconnect and reconnect to diff --git a/redis/connection.py b/redis/connection.py index 4c14233..e39bd39 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -108,7 +108,7 @@ class SocketBuffer(object): while True: data = self._sock.recv(socket_read_size) # an empty string indicates the server shutdown the socket - if isinstance(data, str) and len(data) == 0: + if isinstance(data, bytes) and len(data) == 0: raise socket.error("Connection closed by remote server.") buf.write(data) data_length = len(data) @@ -314,7 +314,7 @@ class HiredisParser(BaseParser): try: buffer = self._sock.recv(socket_read_size) # an empty string indicates the server shutdown the socket - if isinstance(buffer, str) and len(buffer) == 0: + if isinstance(buffer, bytes) and len(buffer) == 0: raise socket.error("Connection closed by remote server.") except socket.timeout: raise TimeoutError("Timeout reading from socket") |