MCPcopy Create free account
hub / github.com/Syncplay/syncplay / StatsRecorder

Class StatsRecorder

syncplay/server.py:306–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304
305
306class StatsRecorder(object):
307 def __init__(self, dbHandle, roomManager):
308 self._dbHandle = dbHandle
309 self._roomManagerHandle = roomManager
310
311 def startRecorder(self, delay):
312 try:
313 self._dbHandle.connect()
314 reactor.callLater(delay, self._scheduleClientSnapshot)
315 except:
316 print("--- Error in initializing the stats database. Server Stats not enabled. ---")
317
318 def _scheduleClientSnapshot(self):
319 self._clientSnapshotTimer = task.LoopingCall(self._runClientSnapshot)
320 self._clientSnapshotTimer.start(constants.SERVER_STATS_SNAPSHOT_INTERVAL)
321
322 def _runClientSnapshot(self):
323 try:
324 snapshotTime = int(time.time())
325 rooms = self._roomManagerHandle.exportRooms()
326 for room in rooms.values():
327 for watcher in room.getWatchers():
328 self._dbHandle.addVersionLog(snapshotTime, watcher.getVersion())
329 except:
330 pass
331
332class RoomsRecorder(StatsRecorder):
333 def __init__(self, dbHandle, roomManager):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected