mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 04:51:31 +00:00
Fix broken ZMQ messages
This commit is contained in:
parent
f374cb7e46
commit
dc76f1b732
@ -42,7 +42,8 @@ def deserialize_tfw_msg(*args):
|
||||
"""
|
||||
Return message from TFW multipart data
|
||||
"""
|
||||
return _deserialize_all(*args)[1]
|
||||
envelope = _deserialize_all(*args)
|
||||
return _repair_if_needed(envelope)
|
||||
|
||||
|
||||
def _serialize_all(*args):
|
||||
@ -84,6 +85,18 @@ def _deserialize_single(data):
|
||||
return _decode_if_needed(data)
|
||||
|
||||
|
||||
def _repair_if_needed(envelope):
|
||||
"""
|
||||
Quick fix for broken messages received from separate processes.
|
||||
"""
|
||||
if len(envelope) == 2:
|
||||
return envelope[1]
|
||||
for part in envelope:
|
||||
if isinstance(part, dict):
|
||||
return part
|
||||
return {}
|
||||
|
||||
|
||||
def _encode_if_needed(value):
|
||||
"""
|
||||
Return input as bytes
|
||||
|
Loading…
Reference in New Issue
Block a user