mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-02-04 09:14:30 +00:00
Fix issue with SSE queues getting lost #3
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
|
||||
import tornado
|
||||
@@ -98,6 +99,22 @@ class WebServer:
|
||||
# Clean up any SSE queues that are growing too large; probably their client disconnected and we didn't catch it
|
||||
# properly for some reason.
|
||||
def clean_up_sse_queues(self):
|
||||
self.sse_spot_queues = [q for q in self.sse_spot_queues if not q.full()]
|
||||
self.sse_alert_queues = [q for q in self.sse_alert_queues if not q.full()]
|
||||
for q in self.sse_spot_queues:
|
||||
try:
|
||||
if q.full():
|
||||
logging.warn("A full SSE spot queue was found, presumably because the client disconnected strangely. It has been removed.")
|
||||
self.sse_spot_queues.remove(q)
|
||||
q.empty()
|
||||
except:
|
||||
# Probably got deleted already on another thread
|
||||
pass
|
||||
for q in self.sse_alert_queues:
|
||||
try:
|
||||
if q.full():
|
||||
logging.warn("A full SSE alert queue was found, presumably because the client disconnected strangely. It has been removed.")
|
||||
self.sse_alert_queues.remove(q)
|
||||
q.empty()
|
||||
except:
|
||||
# Probably got deleted already on another thread
|
||||
pass
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user