mirror of
https://github.com/smittix/intercept.git
synced 2026-07-12 03:28:11 -07:00
Throttle SBS updates to prevent frontend overload
- Batch updates every 1 second instead of every message - Remove verbose MSG,3 debug output - Reduces frontend updates from hundreds/sec to ~1/sec 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+17
-8
@@ -12069,6 +12069,8 @@ def parse_sbs_stream(service_addr):
|
|||||||
|
|
||||||
buffer = ""
|
buffer = ""
|
||||||
msg_count = 0
|
msg_count = 0
|
||||||
|
last_update = time.time()
|
||||||
|
pending_updates = set() # ICAOs with pending updates
|
||||||
while adsb_using_service:
|
while adsb_using_service:
|
||||||
try:
|
try:
|
||||||
data = sock.recv(4096).decode('utf-8', errors='ignore')
|
data = sock.recv(4096).decode('utf-8', errors='ignore')
|
||||||
@@ -12102,7 +12104,6 @@ def parse_sbs_stream(service_addr):
|
|||||||
|
|
||||||
# MSG,3: position (alt, lat, lon)
|
# MSG,3: position (alt, lat, lon)
|
||||||
elif msg_type == '3':
|
elif msg_type == '3':
|
||||||
print(f"[ADS-B] MSG,3 received: parts={len(parts)}, lat={parts[14] if len(parts)>14 else 'N/A'}, lon={parts[15] if len(parts)>15 else 'N/A'}")
|
|
||||||
if len(parts) > 15:
|
if len(parts) > 15:
|
||||||
if parts[11]:
|
if parts[11]:
|
||||||
try:
|
try:
|
||||||
@@ -12150,14 +12151,22 @@ def parse_sbs_stream(service_addr):
|
|||||||
aircraft['squawk'] = parts[17]
|
aircraft['squawk'] = parts[17]
|
||||||
|
|
||||||
adsb_aircraft[icao] = aircraft
|
adsb_aircraft[icao] = aircraft
|
||||||
adsb_queue.put({
|
pending_updates.add(icao)
|
||||||
'type': 'aircraft',
|
|
||||||
**aircraft
|
|
||||||
})
|
|
||||||
|
|
||||||
msg_count += 1
|
msg_count += 1
|
||||||
if msg_count % 100 == 0:
|
|
||||||
print(f"[ADS-B] SBS: Processed {msg_count} messages, tracking {len(adsb_aircraft)} aircraft")
|
# Throttle updates to frontend - send every 1 second
|
||||||
|
now = time.time()
|
||||||
|
if now - last_update >= 1.0:
|
||||||
|
for update_icao in pending_updates:
|
||||||
|
if update_icao in adsb_aircraft:
|
||||||
|
adsb_queue.put({
|
||||||
|
'type': 'aircraft',
|
||||||
|
**adsb_aircraft[update_icao]
|
||||||
|
})
|
||||||
|
pending_updates.clear()
|
||||||
|
last_update = now
|
||||||
|
if msg_count % 500 == 0:
|
||||||
|
print(f"[ADS-B] SBS: Processed {msg_count} messages, tracking {len(adsb_aircraft)} aircraft")
|
||||||
|
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user