summaryrefslogtreecommitdiff
path: root/redis/connection.py
diff options
context:
space:
mode:
authorZac Bristow <zbristow@codeaurora.org>2019-09-20 15:20:08 -0700
committerAndy McCurdy <andy@andymccurdy.com>2019-10-10 14:10:16 -0700
commita03c12e5869469aeaf4016d75a883a1fceb992fd (patch)
treece24ae73f68ba2554798f6dd744f2a582fb7f0e5 /redis/connection.py
parent29a5259f644da35baee25342dc097782527d854b (diff)
downloadredis-py-a03c12e5869469aeaf4016d75a883a1fceb992fd.tar.gz
Version 3.3.93.3.9
Fixes SSL read timeouts in Python 2.7 The ssl module in Python 2.7 raises timeouts as ssl.SSLError instead of socket.timeout. When these timeouts are encountered, the error will be re-raised as socket.timeout so it is handled appropriately by the connection.
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-xredis/connection.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/redis/connection.py b/redis/connection.py
index 333bd75..feea041 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -13,7 +13,8 @@ import warnings
from redis._compat import (xrange, imap, byte_to_chr, unicode, long,
nativestr, basestring, iteritems,
LifoQueue, Empty, Full, urlparse, parse_qs,
- recv, recv_into, unquote, BlockingIOError)
+ recv, recv_into, unquote, BlockingIOError,
+ sendall, shutdown, ssl_wrap_socket)
from redis.exceptions import (
AuthenticationError,
BusyLoadingError,
@@ -630,7 +631,7 @@ class Connection(object):
return
try:
if os.getpid() == self.pid:
- self._sock.shutdown(socket.SHUT_RDWR)
+ shutdown(self._sock, socket.SHUT_RDWR)
self._sock.close()
except socket.error:
pass
@@ -662,7 +663,7 @@ class Connection(object):
if isinstance(command, str):
command = [command]
for item in command:
- self._sock.sendall(item)
+ sendall(self._sock, item)
except socket.timeout:
self.disconnect()
raise TimeoutError("Timeout writing to socket")
@@ -815,11 +816,12 @@ class SSLConnection(Connection):
keyfile=self.keyfile)
if self.ca_certs:
context.load_verify_locations(self.ca_certs)
- sock = context.wrap_socket(sock, server_hostname=self.host)
+ sock = ssl_wrap_socket(context, sock, server_hostname=self.host)
else:
# In case this code runs in a version which is older than 2.7.9,
# we want to fall back to old code
- sock = ssl.wrap_socket(sock,
+ sock = ssl_wrap_socket(ssl,
+ sock,
cert_reqs=self.cert_reqs,
keyfile=self.keyfile,
certfile=self.certfile,