mirror of
https://github.com/smittix/intercept.git
synced 2026-07-17 05:48:11 -07:00
perf: move ADS-B SSE snapshot priming into generator
This commit is contained in:
+7
-8
@@ -1281,15 +1281,14 @@ def stream_adsb():
|
|||||||
with _adsb_stream_subscribers_lock:
|
with _adsb_stream_subscribers_lock:
|
||||||
_adsb_stream_subscribers.add(client_queue)
|
_adsb_stream_subscribers.add(client_queue)
|
||||||
|
|
||||||
# Prime new clients with current known aircraft so they don't wait for the
|
|
||||||
# next positional update before rendering.
|
|
||||||
for snapshot in list(app_module.adsb_aircraft.values()):
|
|
||||||
try:
|
|
||||||
client_queue.put_nowait({"type": "aircraft", **snapshot})
|
|
||||||
except queue.Full:
|
|
||||||
break
|
|
||||||
|
|
||||||
def generate():
|
def generate():
|
||||||
|
# Prime with current aircraft snapshot before entering the live loop.
|
||||||
|
for snapshot in list(app_module.adsb_aircraft.values()):
|
||||||
|
try:
|
||||||
|
client_queue.put_nowait({"type": "aircraft", **snapshot})
|
||||||
|
except queue.Full:
|
||||||
|
break
|
||||||
|
|
||||||
last_keepalive = time.time()
|
last_keepalive = time.time()
|
||||||
# Send immediate keepalive so Werkzeug dev server flushes response
|
# Send immediate keepalive so Werkzeug dev server flushes response
|
||||||
# headers right away (it buffers until first body byte is written).
|
# headers right away (it buffers until first body byte is written).
|
||||||
|
|||||||
Reference in New Issue
Block a user