Harden live material polling state
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user