Skip to content

Commit 4a5077d

Browse files
committed
Handle deserializing older SharQ payloads
...that were present before moving to python3 where the payload format changed. Signed-off-by: Prashanth Pai <prashanth.pai@plivo.com>
1 parent 4fed455 commit 4a5077d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sharq/queue.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ def dequeue(self, queue_type='default'):
217217
return response
218218

219219
queue_id, job_id, payload, requeues_remaining = dequeue_response
220+
221+
if payload is None:
222+
response = {
223+
'status': 'failure'
224+
}
225+
return response
226+
220227
payload = deserialize_payload(payload)
221228

222229
response = {

sharq/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ def serialize_payload(payload):
6565
def deserialize_payload(payload):
6666
"""Tries to deserialize the payload using msgpack.
6767
"""
68+
# Handle older SharQ payloads as well (before py3 migration)
69+
if payload.startswith(b'"') and payload.endswith(b'"'):
70+
return msgpack.unpackb(payload[1:-1], raw=False)
71+
6872
return msgpack.unpackb(payload, raw=False)
6973

7074

@@ -83,4 +87,4 @@ def convert_to_str(queue_set):
8387
except Exception as e:
8488
queue_list.append(queue)
8589
pass
86-
return queue_list
90+
return queue_list

0 commit comments

Comments
 (0)