Skip to content

Commit a32a8e6

Browse files
author
Roey Prat
committed
XREAD and XREADGROUP return empty lists when the server returns no messages
1 parent b7cd888 commit a32a8e6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

redis/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ def parse_xclaim(response):
266266
return stream_list(response)
267267

268268

269-
def parse_xreadgroup(response):
269+
def parse_xread(response):
270270
if response is None:
271-
return None
271+
return []
272272
return [[nativestr(r[0]), stream_list(r[1])] for r in response]
273273

274274

@@ -441,7 +441,7 @@ class StrictRedis(object):
441441
),
442442
string_keys_to_dict('XREVRANGE XRANGE', stream_list),
443443
string_keys_to_dict('XPENDING', parse_xpending),
444-
string_keys_to_dict('XREAD XREADGROUP', parse_xreadgroup),
444+
string_keys_to_dict('XREAD XREADGROUP', parse_xread),
445445
{
446446
'XGROUP CREATE': bool_ok,
447447
'XGROUP DESTROY': int,

tests/test_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ def test_strict_xread(self, sr):
16601660
assert stamp1 != stamp2
16611661

16621662
results = sr.xread(streams={varname: '$'}, count=10, block=10)
1663-
assert results is None
1663+
assert results == []
16641664

16651665
results = sr.xread(count=3, block=0, streams={varname: stamp1})
16661666
assert results[0][1][0][0] == stamp2

0 commit comments

Comments
 (0)