connection.py 文件源码

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

项目:smileybot 作者: sillylyn 项目源码 文件源码
def send_json(self, data):
        """
        send_json(data) -> Bool

        Send json data into the stream. Returns false on message fail.
        """

        now = time.time()
        if self.limit != 0 and now - self.last_packet < self.limit:
            time.sleep(self.limit - (now - self.last_packet))

        try:
            self.socket.send(json.dumps(data))
        except (AttributeError, websocket.WebSocketException):
            with self.lock:
                self.socket = None
            return False

        self.last_packet = time.time()

        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号