From 2716fbf1aafb9f814a8bbcac59f325a935220fb9 Mon Sep 17 00:00:00 2001 From: Richard Bronkhorst Date: Tue, 18 Jul 2023 12:43:31 +0200 Subject: [PATCH] Update atlas_builder.py, central_command.py and one other file --- nullptr/atlas_builder.py | 4 +++- nullptr/central_command.py | 2 ++ nullptr/store.py | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/nullptr/atlas_builder.py b/nullptr/atlas_builder.py index 1ee5979..8587cba 100644 --- a/nullptr/atlas_builder.py +++ b/nullptr/atlas_builder.py @@ -16,7 +16,8 @@ class AtlasBuilder: def find_work(self): first_page = self.atlas.total_pages == 0 - pages_left = self.atlas.total_pages < self.atlas.seen_pages + pages_left = self.atlas.total_pages > self.atlas.seen_pages + if first_page or pages_left: self.sched(self.get_systems) return @@ -43,6 +44,7 @@ class AtlasBuilder: page = self.atlas.seen_pages + 1 if page > self.atlas.total_pages: return + # print('systems', page) data = self.api.list_systems(page) self.atlas.total_pages = total_pages(self.api.last_meta) self.atlas.seen_pages = page diff --git a/nullptr/central_command.py b/nullptr/central_command.py index 6c2398f..9a880b9 100644 --- a/nullptr/central_command.py +++ b/nullptr/central_command.py @@ -60,6 +60,8 @@ class CentralCommand: did_step = self.tick() if request_counter == self.api.requests_sent: self.atlas_builder.do_work() + else: + print('nowork') self.store.flush() sleep(0.5) diff --git a/nullptr/store.py b/nullptr/store.py index 0235da4..617471e 100644 --- a/nullptr/store.py +++ b/nullptr/store.py @@ -251,6 +251,7 @@ class Store: def cleanup(self): if time() < self.last_cleanup + self.cleanup_interval: return + self.last_cleanup = time() start_time = time() expired = list() for t in self.data: @@ -262,7 +263,7 @@ class Store: del self.data[type(o)][o.symbol] dur = time() - start_time - # print(f'cleaned {len(expired)} in {dur:.03f} seconds') + print(f'cleaned {len(expired)} in {dur:.03f} seconds') def flush(self): self.cleanup() @@ -277,7 +278,7 @@ class Store: self.fil.flush() self.dirty_objects = set() dur = time() - start_time - # print(f'flush done {it} items {dur:.2f}') + # print(f'flush done {it} items {dur:.2f}') def defrag(self): nm = self.fil.name