Harden live material polling state

This commit is contained in:
2026-09-05 05:50:01 +02:00
parent 98a92c3739
commit efc563512f
9 changed files with 513 additions and 40 deletions
@@ -65,8 +65,10 @@ class MaterialPollingService:
)
def poll_once(self, *, now: datetime) -> MaterialPollResult | None:
if now.tzinfo is None or now.utcoffset() is None:
raise ValueError("now must be timezone-aware")
run = self._gateway.get_open_production_run(self._machine_id)
if run is None:
if run is None or now < run.start:
return None
saved_polling_state = self._state_store.load(
@@ -92,6 +94,9 @@ class MaterialPollingService:
)
start = run.start
if now < start:
return None
integrator = MaterialConsumptionIntegrator(
self._config,
initial_state=initial_state,