protocol.py 文件源码

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

项目:felix 作者: axbaretto 项目源码 文件源码
def send_message(self, msg_type, fields=None, flush=True):
        """
        Send a message of the given type with the given fields.
        Optionally, flush the data to the socket.

        This method will flush the buffer if it grows too large in any
        case.

        :param msg_type: one of the MSG_TYPE_* constants.
        :param dict fields: dict mapping MSG_KEY_* constants to values.
        :param flush: True to force the data to be written immediately.
        """
        msg = {MSG_KEY_TYPE: msg_type}
        if fields:
            msg.update(fields)
        self._buf.write(msgpack.dumps(msg))
        if flush:
            self.flush()
        else:
            self._maybe_flush()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号