Skip to content

Commit 038e5ee

Browse files
committed
version 3.3.6, fixed a regression in 3.3.5 with pubsub timeouts
Fixes redis#1200
1 parent a5ba696 commit 038e5ee

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* 3.3.6
2+
* Fixed a regression in 3.3.5 that caused PubSub.get_message() to raise
3+
a socket.timeout exception when passing a timeout value. #1200
14
* 3.3.5
25
* Fix an issue where socket.timeout errors could be handled by the wrong
36
exception handler in Python 2.7.

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.5'
32+
__version__ = '3.3.6'
3333
VERSION = tuple(map(int_or_str, __version__.split('.')))
3434

3535
__all__ = [

redis/connection.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ def _read_from_socket(self, length=None, timeout=SENTINEL,
182182
if length is not None and length > marker:
183183
continue
184184
return True
185+
except socket.timeout:
186+
if raise_on_timeout:
187+
raise
188+
return False
185189
except NONBLOCKING_EXCEPTIONS as ex:
186190
# if we're in nonblocking mode and the recv raises a
187191
# blocking error, simply return False indicating that
@@ -408,6 +412,10 @@ def read_from_socket(self, timeout=SENTINEL, raise_on_timeout=True):
408412
# data was read from the socket and added to the buffer.
409413
# return True to indicate that data was read.
410414
return True
415+
except socket.timeout:
416+
if raise_on_timeout:
417+
raise
418+
return False
411419
except NONBLOCKING_EXCEPTIONS as ex:
412420
# if we're in nonblocking mode and the recv raises a
413421
# blocking error, simply return False indicating that

tests/test_pubsub.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,3 +531,11 @@ def test_connection_error_raised_when_connection_dies(self, r):
531531
r.client_kill_filter(_id=client['id'])
532532
with pytest.raises(ConnectionError):
533533
wait_for_message(p)
534+
535+
536+
class TestPubSubTimeouts(object):
537+
def test_get_message_with_timeout_returns_none(self, r):
538+
p = r.pubsub()
539+
p.subscribe('foo')
540+
assert wait_for_message(p) == make_message('subscribe', 'foo', 1)
541+
assert p.get_message(timeout=0.01) is None

0 commit comments

Comments
 (0)