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 <noreply@anthropic.com>
This commit is contained in:
Dominik Moritz Roth 2026-03-12 17:53:35 +01:00
parent 088b7d4733
commit c3111ad5be

View File

@ -166,8 +166,17 @@ class NuconModelLearner:
'ALARMS_ACTIVE', 'FUN_IS_ENABLED', 'GAME_SIM_SPEED'}) 'ALARMS_ACTIVE', 'FUN_IS_ENABLED', 'GAME_SIM_SPEED'})
candidate_params = {k: p for k, p in self.nucon.get_all_readable().items() 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} if k not in _JUNK_PARAMS and p.param_type != str}
# Filter out params that return None (subsystem not installed) # 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} 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.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 self.non_writable_params = [k for k in self.readable_params
if not self.nucon.get_all_readable()[k].is_writable] if not self.nucon.get_all_readable()[k].is_writable]