Skip to content

Commit

Permalink
Fix: check redis response type
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiix authored and auvipy committed Sep 16, 2021
1 parent 07bab02 commit 580b521
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kombu/transport/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ def _receive_one(self, c):
except self.connection_errors:
self._in_listen = None
raise
if response is not None:
if isinstance(response, (list, tuple)):
payload = self._handle_message(c, response)
if bytes_to_str(payload['type']).endswith('message'):
channel = bytes_to_str(payload['channel'])
Expand Down
6 changes: 6 additions & 0 deletions t/unit/transport/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,12 @@ def test_receive_different_message_Type(self):

assert self.channel._receive_one(self.channel.subclient) is None

def test_receive_invalid_response_type(self):
s = self.channel.subclient = Mock()
for resp in ['foo', None]:
s.parse_response.return_value = resp
assert self.channel._receive_one(self.channel.subclient) is None

def test_receive_connection_has_gone(self):
def _receive_one(c):
c.connection = None
Expand Down

0 comments on commit 580b521

Please sign in to comment.