Skip to content

Commit e897c17

Browse files
committed
version 3.3.1, fixed a regression involving SSL and non-blocking sockets
Fixes #1197
1 parent 0de7c82 commit e897c17

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* 3.3.1
2+
* Fixed a regression introduced in 3.3.1 involving SSL and non-blocking
3+
sockets. #1197
14
* 3.3.0
25
* Resolve a race condition with the PubSubWorkerThread. #1150
36
* Cleanup socket read error messages. Thanks Vic Yu. #1159

redis/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def int_or_str(value):
2929
return value
3030

3131

32-
__version__ = '3.3.0'
32+
__version__ = '3.3.1'
3333
VERSION = tuple(map(int_or_str, __version__.split('.')))
3434

3535
__all__ = [

redis/connection.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
import threading
1111
import warnings
1212

13-
try:
14-
import ssl
15-
ssl_available = True
16-
except ImportError:
17-
ssl_available = False
18-
1913
from redis._compat import (xrange, imap, byte_to_chr, unicode, long,
2014
nativestr, basestring, iteritems,
2115
LifoQueue, Empty, Full, urlparse, parse_qs,
@@ -34,6 +28,23 @@
3428
TimeoutError,
3529
)
3630
from redis.utils import HIREDIS_AVAILABLE
31+
32+
try:
33+
import ssl
34+
ssl_available = True
35+
except ImportError:
36+
ssl_available = False
37+
38+
if ssl_available:
39+
blocking_exceptions = (
40+
BlockingIOError,
41+
ssl.SSLWantReadError,
42+
ssl.SSLWantWriteError
43+
)
44+
else:
45+
blocking_exceptions = (BlockingIOError,)
46+
47+
3748
if HIREDIS_AVAILABLE:
3849
import hiredis
3950

@@ -168,7 +179,7 @@ def _read_from_socket(self, length=None, timeout=SENTINEL,
168179
if length is not None and length > marker:
169180
continue
170181
return True
171-
except BlockingIOError as ex:
182+
except blocking_exceptions as ex:
172183
# if we're in nonblocking mode and the recv raises a
173184
# blocking error, simply return False indicating that
174185
# there's no data to be read. otherwise raise the
@@ -397,7 +408,7 @@ def read_from_socket(self, timeout=SENTINEL, raise_on_timeout=True):
397408
# data was read from the socket and added to the buffer.
398409
# return True to indicate that data was read.
399410
return True
400-
except BlockingIOError as ex:
411+
except blocking_exceptions as ex:
401412
# if we're in nonblocking mode and the recv raises a
402413
# blocking error, simply return False indicating that
403414
# there's no data to be read. otherwise raise the

0 commit comments

Comments
 (0)