Refactor of caching & data storage part 16 #118

This commit is contained in:
Ian Renton
2026-08-03 22:15:29 +01:00
parent 27d73c27d6
commit 459d999f57
14 changed files with 93 additions and 55 deletions
+5 -2
View File
@@ -11,6 +11,9 @@ class SSEBroadcaster:
def __init__(self):
self._handlers = set()
self._lock = threading.Lock()
self._loop = None
def bind_to_web_server_loop(self):
self._loop = IOLoop.current()
def register(self, handler):
@@ -22,9 +25,9 @@ class SSEBroadcaster:
self._handlers.discard(handler)
def publish(self, value):
self._loop.add_callback(self._fan_out, value)
self._loop.add_callback(self._broadcast, value)
def _fan_out(self, value):
def _broadcast(self, value):
with self._lock:
handlers = list(self._handlers)
for handler in handlers: