common.py 文件源码

python
阅读 43 收藏 0 点赞 0 评论 0

项目:osbrain 作者: opensistemas-hub 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号