def topics_to_bytes(handlers: Dict[Union[bytes, str], Any], uuid: bytes = b''):
'''
Given some pairs topic/handler, leaves them prepared for making the actual
ZeroMQ subscription.
Parameters
----------
handlers
Contains pairs "topic - handler".
uuid
uuid of the SYNC_PUB/SYNC_SUB channel (if applies). For normal
PUB/SUB communication, this should be `b''`.
Returns
-------
Dict[bytes, Any]
'''
curated_handlers = {}
for topic, value in handlers.items():
topic = topic_to_bytes(topic)
curated_handlers[uuid + topic] = value
return curated_handlers
评论列表
文章目录