From c3111ad5be8e3414eb4db3c418a28306127d4a6b Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Mar 2026 17:53:35 +0100 Subject: [PATCH] fix: retry game connection in __init__ as well as collect_data The None-param filtering probe at init also needs to wait for the game to be reachable, not just the collection loop. Co-Authored-By: Claude Sonnet 4.6 --- nucon/model.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nucon/model.py b/nucon/model.py index 85fd6a1..976611b 100644 --- a/nucon/model.py +++ b/nucon/model.py @@ -166,8 +166,17 @@ class NuconModelLearner: 'ALARMS_ACTIVE', 'FUN_IS_ENABLED', 'GAME_SIM_SPEED'}) candidate_params = {k: p for k, p in self.nucon.get_all_readable().items() if k not in _JUNK_PARAMS and p.param_type != str} - # Filter out params that return None (subsystem not installed) - test_state = {k: self.nucon.get(k) for k in candidate_params} + # Filter out params that return None (subsystem not installed). + # Retry until the game is reachable. + import requests as _requests + while True: + try: + test_state = {k: self.nucon.get(k) for k in candidate_params} + break + except (_requests.exceptions.ConnectionError, + _requests.exceptions.Timeout): + print("Waiting for game to be reachable…") + time.sleep(5) self.readable_params = [k for k in candidate_params if test_state[k] is not None] self.non_writable_params = [k for k in self.readable_params if not self.nucon.get_all_readable()[k].is_writable]