Skip to content

Commit efaf9c9

Browse files
committed
poller: save state before waiting for workers
If workers hang stopping them will fail and we'll never save the processing state. Looks like this has be broken for a while. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 88c3ba7 commit efaf9c9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pw_poller.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ def run(self, life) -> None:
249249
except KeyboardInterrupt:
250250
pass # finally will still run, but don't splat
251251
finally:
252+
# Dump state before trying to stop workers, in case they hang
253+
self._state['last_poll'] = prev_big_scan.timestamp()
254+
self._state['done_series'] = list(self.seen_series)
255+
with open('poller.state', 'w') as f:
256+
json.dump(self._state, f)
257+
252258
log_open_sec(f"Stopping threads")
253259
for worker in self._workers:
254260
worker.should_die = True
@@ -258,12 +264,6 @@ def run(self, life) -> None:
258264
worker.join()
259265
log_end_sec()
260266

261-
self._state['last_poll'] = prev_big_scan.timestamp()
262-
self._state['done_series'] = list(self.seen_series)
263-
# Dump state
264-
with open('poller.state', 'w') as f:
265-
json.dump(self._state, f)
266-
267267

268268
if __name__ == "__main__":
269269
os.umask(0o002)

0 commit comments

Comments
 (0)