Skip to content

Commit

Permalink
check for the server closing a connection that's compatible with Pyth…
Browse files Browse the repository at this point in the history
…on 3

fixes #508
  • Loading branch information
andymccurdy committed Jul 7, 2014
1 parent 310cb1c commit 83013b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _read_from_socket(self, length=None):
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)
Expand Down Expand Up @@ -314,7 +314,7 @@ def read_response(self):
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")
Expand Down

0 comments on commit 83013b5

Please sign in to comment.