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
评论列表
文章目录