summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2019-08-06 10:59:38 -0700
committerAndy McCurdy <andy@andymccurdy.com>2019-08-06 10:59:38 -0700
commit038e5ee019ecaa29b073a89e61585d404579beff (patch)
tree60aa92db2980aa10d8f5019dff046d332c663daa
parenta5ba696ed8aa3efbc709de4046a121a82a31392f (diff)
downloadredis-py-038e5ee019ecaa29b073a89e61585d404579beff.tar.gz
version 3.3.6, fixed a regression in 3.3.5 with pubsub timeouts3.3.6
Fixes #1200
-rw-r--r--CHANGES3
-rw-r--r--redis/__init__.py2
-rwxr-xr-xredis/connection.py8
-rw-r--r--tests/test_pubsub.py8
4 files changed, 20 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index fd58905..cc61dad 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+* 3.3.6
+ * Fixed a regression in 3.3.5 that caused PubSub.get_message() to raise
+ a socket.timeout exception when passing a timeout value. #1200
* 3.3.5
* Fix an issue where socket.timeout errors could be handled by the wrong
exception handler in Python 2.7.
diff --git a/redis/__init__.py b/redis/__init__.py
index 66ef979..6200d4d 100644
--- a/redis/__init__.py
+++ b/redis/__init__.py
@@ -29,7 +29,7 @@ def int_or_str(value):
return value
-__version__ = '3.3.5'
+__version__ = '3.3.6'
VERSION = tuple(map(int_or_str, __version__.split('.')))
__all__ = [
diff --git a/redis/connection.py b/redis/connection.py
index 151d4d0..3a0ae65 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -182,6 +182,10 @@ class SocketBuffer(object):
if length is not None and length > marker:
continue
return True
+ except socket.timeout:
+ if raise_on_timeout:
+ raise
+ return False
except NONBLOCKING_EXCEPTIONS as ex:
# if we're in nonblocking mode and the recv raises a
# blocking error, simply return False indicating that
@@ -408,6 +412,10 @@ 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 socket.timeout:
+ if raise_on_timeout:
+ raise
+ return False
except NONBLOCKING_EXCEPTIONS as ex:
# if we're in nonblocking mode and the recv raises a
# blocking error, simply return False indicating that
diff --git a/tests/test_pubsub.py b/tests/test_pubsub.py
index fee04da..2644d60 100644
--- a/tests/test_pubsub.py
+++ b/tests/test_pubsub.py
@@ -531,3 +531,11 @@ class TestPubSubConnectionKilled(object):
r.client_kill_filter(_id=client['id'])
with pytest.raises(ConnectionError):
wait_for_message(p)
+
+
+class TestPubSubTimeouts(object):
+ def test_get_message_with_timeout_returns_none(self, r):
+ p = r.pubsub()
+ p.subscribe('foo')
+ assert wait_for_message(p) == make_message('subscribe', 'foo', 1)
+ assert p.get_message(timeout=0.01) is None