server: guard against None snapshots crashing the accept loop
If extract_all() returns None (Dashboard init failure), appending it to store["records"] would cause _accept_loop to crash with AttributeError on the next client connection. Since only OSError was caught, the thread died permanently — no further clients could join push_clients, so live broadcasts reached nobody. - collect.py: skip None snapshots instead of appending them - network.py: filter None records in _accept_loop; catch all exceptions during history send (not just OSError) so the thread survives - storage_helpers.py: filter None records when loading from disk Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-2
@@ -49,7 +49,7 @@ def run(args: argparse.Namespace) -> None:
|
||||
push_clients, push_lock, push_store_ref = network.start_push_server(args.host, args.port)
|
||||
push_store_ref["preloaded"] = load_last_24h_records(logs_dir, vin)
|
||||
for _r in push_store_ref["preloaded"]:
|
||||
if "procedural" not in _r:
|
||||
if _r is not None and "procedural" not in _r:
|
||||
apply_procedural(_r)
|
||||
if push_store_ref["preloaded"]:
|
||||
log.info("Pre-loaded %d record(s) from the last 24 h", len(push_store_ref["preloaded"]))
|
||||
@@ -57,7 +57,7 @@ def run(args: argparse.Namespace) -> None:
|
||||
current_day = datetime.now(timezone.utc).date()
|
||||
store = load_store(out, vin, args.interval)
|
||||
for _r in store["records"]:
|
||||
if "procedural" not in _r:
|
||||
if _r is not None and "procedural" not in _r:
|
||||
apply_procedural(_r)
|
||||
push_store_ref["current"] = store
|
||||
last_broadcast: dict = {}
|
||||
@@ -86,6 +86,9 @@ def run(args: argparse.Namespace) -> None:
|
||||
try:
|
||||
we_connect.update(wc)
|
||||
snapshot = extract_all(vehicle)
|
||||
if snapshot is None:
|
||||
log.warning("extract_all returned None — skipping this cycle")
|
||||
continue
|
||||
snapshot = apply_procedural(snapshot)
|
||||
store["records"].append(snapshot)
|
||||
save_store(out, store, args.max_records)
|
||||
|
||||
Reference in New Issue
Block a user