summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2019-07-29 10:53:24 -0700
committerAndy McCurdy <andy@andymccurdy.com>2019-07-29 10:53:24 -0700
commite897c174483275fcb333e02bf36353a6afee44b4 (patch)
treed2a3d1636347d4bfab34c17a17f767af8f766b4a
parent0de7c82028b81f025424df92620b31d6567e175e (diff)
downloadredis-py-e897c174483275fcb333e02bf36353a6afee44b4.tar.gz
version 3.3.1, fixed a regression involving SSL and non-blocking sockets3.3.1
Fixes #1197
-rw-r--r--CHANGES3
-rw-r--r--redis/__init__.py2
-rwxr-xr-xredis/connection.py27
3 files changed, 23 insertions, 9 deletions
diff --git a/CHANGES b/CHANGES
index 18e9416..e46f1f6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+* 3.3.1
+ * Fixed a regression introduced in 3.3.1 involving SSL and non-blocking
+ sockets. #1197
* 3.3.0
* Resolve a race condition with the PubSubWorkerThread. #1150
* Cleanup socket read error messages. Thanks Vic Yu. #1159
diff --git a/redis/__init__.py b/redis/__init__.py
index cca895b..63b8d9d 100644
--- a/redis/__init__.py
+++ b/redis/__init__.py
@@ -29,7 +29,7 @@ def int_or_str(value):
return value
-__version__ = '3.3.0'
+__version__ = '3.3.1'
VERSION = tuple(map(int_or_str, __version__.split('.')))
__all__ = [
diff --git a/redis/connection.py b/redis/connection.py
index b60a9fd..5ec2f2e 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -10,12 +10,6 @@ import sys
import threading
import warnings
-try:
- import ssl
- ssl_available = True
-except ImportError:
- ssl_available = False
-
from redis._compat import (xrange, imap, byte_to_chr, unicode, long,
nativestr, basestring, iteritems,
LifoQueue, Empty, Full, urlparse, parse_qs,
@@ -34,6 +28,23 @@ from redis.exceptions import (
TimeoutError,
)
from redis.utils import HIREDIS_AVAILABLE
+
+try:
+ import ssl
+ ssl_available = True
+except ImportError:
+ ssl_available = False
+
+if ssl_available:
+ blocking_exceptions = (
+ BlockingIOError,
+ ssl.SSLWantReadError,
+ ssl.SSLWantWriteError
+ )
+else:
+ blocking_exceptions = (BlockingIOError,)
+
+
if HIREDIS_AVAILABLE:
import hiredis
@@ -168,7 +179,7 @@ class SocketBuffer(object):
if length is not None and length > marker:
continue
return True
- except BlockingIOError as ex:
+ except blocking_exceptions as ex:
# if we're in nonblocking mode and the recv raises a
# blocking error, simply return False indicating that
# there's no data to be read. otherwise raise the
@@ -397,7 +408,7 @@ class HiredisParser(BaseParser):
# data was read from the socket and added to the buffer.
# return True to indicate that data was read.
return True
- except BlockingIOError as ex:
+ except blocking_exceptions as ex:
# if we're in nonblocking mode and the recv raises a
# blocking error, simply return False indicating that
# there's no data to be read. otherwise raise the