Skip to content

Commit

Permalink
Send WS updates on threads
Browse files Browse the repository at this point in the history
Hopefully that means that clients that are blocking do not hold up the entire process.
  • Loading branch information
stblassitude committed Dec 23, 2023
1 parent 00b6d93 commit 1c72823
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mumblestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,19 @@ def collect_stats(self):
while self.running:
for channel in self.channels:
if not self.stats[channel].is_alive():
print('{} is not alive anymore'.format(channel))
#print('{} is not alive anymore'.format(channel))
return
self.stats[channel].update_stats()
stats = self.get_stats()
self.update_prometheus_metrics(stats)
wsjson = json.dumps(stats)
for ws in self.wsstats_clients:
ws.send(wsjson)
def send():
try:
ws.send(wsjson)
except Exception:
self.wsstats_clients.remove(ws)
t = threading.Thread(target=send, daemon=True).start()
time.sleep(.1)
for channel in self.channels:
self.mumble_close(self.stats[channel])
Expand Down

0 comments on commit 1c72823

Please sign in to comment.