Skip to content

Commit

Permalink
Handle new XAUTOCLAIM response introduced in redis>=4.3.4
Browse files Browse the repository at this point in the history
[A breaking change](redis/redis-py#2252) in `redis==4.3.4` breaks Cog.

This PR handles the new XAUTOCLAIM response format in a backwards-compatible way.

Closes replicate#671

Signed-off-by: andreasjansson <andreas@replicate.ai>
  • Loading branch information
andreasjansson committed Jun 28, 2022
1 parent 91a2745 commit 1a5b375
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/cog/server/redis_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def receive_message(self) -> Tuple[Optional[str], Optional[str]]:
1,
)
# format: [[b'1619393873567-0', [b'mykey', b'myval']]]
if raw_messages and raw_messages[0] is not None:
# since redis==4.3.4 an empty response from xautoclaim is indicated by [[b'0-0', []]]
if raw_messages and raw_messages[0] is not None and len(raw_messages[0]) == 2:
key, raw_message = raw_messages[0]
assert raw_message[0] == b"value"
return key.decode(), raw_message[1].decode()
Expand Down

0 comments on commit 1a5b375

Please sign in to comment.