def update_urwid(self):
interval = .1
status_line = "{hostname} | Connections: [{current}/{total}] | Total Messages: {message_count} | Messages/Second: {msgs_per_second}/s"
while True:
if self._exiting:
return True
#raise urwid.ExitMainLoop
# Only update things a max of 10 times/second
yield from asyncio.sleep(interval)
# Get the current global message count
global_message_count = int(repr(self.global_message_counter)[6:-1])
self.ring_buffer.append(global_message_count)
currently_connected_sockets = len([x for x in self.sockets.values() if x and not isinstance(x, BaseException) and x.ws.state == OPEN])
self.logger.update_graph_data([self.messages_per_second,])
# Get and update our blinkboard widget
self.blinkboard.generate_blinkers(self.sockets)
# Make the status message
status_message = status_line.format(
hostname=self.websocket_url.netloc,
current=currently_connected_sockets,
total=self.total_connections,
message_count=global_message_count,
msgs_per_second=self.messages_per_second
)
self.frame.footer.set_text(status_message)
评论列表
文章目录