MCPcopy Create free account
hub / github.com/miguelgrinberg/python-socketio / _emit_server_stats

Method _emit_server_stats

src/socketio/admin.py:348–369  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

346 return socket.__send_ping()
347
348 def _emit_server_stats(self):
349 start_time = time.time()
350 namespaces = list(self.sio.handlers.keys())
351 namespaces.sort()
352 while not self.stop_stats_event.is_set():
353 self.sio.sleep(self.server_stats_interval)
354 self.sio.emit('server_stats', {
355 'serverId': self.server_id,
356 'hostname': HOSTNAME,
357 'pid': PID,
358 'uptime': time.time() - start_time,
359 'clientsCount': len(self.sio.eio.sockets),
360 'pollingClientsCount': len(
361 [s for s in self.sio.eio.sockets.values()
362 if not s.upgraded]),
363 'aggregatedEvents': self.event_buffer.get_and_clear(),
364 'namespaces': [{
365 'name': nsp,
366 'socketsCount': len(self.sio.manager.rooms.get(
367 nsp, {None: []}).get(None, []))
368 } for nsp in namespaces],
369 }, namespace=self.admin_namespace)
370
371 def serialize_socket(self, sid, namespace, eio_sid=None):
372 if eio_sid is None: # pragma: no cover

Callers

nothing calls this directly

Calls 4

get_and_clearMethod · 0.80
sleepMethod · 0.45
emitMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected