Update atlas_builder.py, central_command.py and one other file
This commit is contained in:
parent
71f8eb9ed8
commit
2716fbf1aa
@ -16,7 +16,8 @@ class AtlasBuilder:
|
|||||||
|
|
||||||
def find_work(self):
|
def find_work(self):
|
||||||
first_page = self.atlas.total_pages == 0
|
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:
|
if first_page or pages_left:
|
||||||
self.sched(self.get_systems)
|
self.sched(self.get_systems)
|
||||||
return
|
return
|
||||||
@ -43,6 +44,7 @@ class AtlasBuilder:
|
|||||||
page = self.atlas.seen_pages + 1
|
page = self.atlas.seen_pages + 1
|
||||||
if page > self.atlas.total_pages:
|
if page > self.atlas.total_pages:
|
||||||
return
|
return
|
||||||
|
# print('systems', page)
|
||||||
data = self.api.list_systems(page)
|
data = self.api.list_systems(page)
|
||||||
self.atlas.total_pages = total_pages(self.api.last_meta)
|
self.atlas.total_pages = total_pages(self.api.last_meta)
|
||||||
self.atlas.seen_pages = page
|
self.atlas.seen_pages = page
|
||||||
|
@ -60,6 +60,8 @@ class CentralCommand:
|
|||||||
did_step = self.tick()
|
did_step = self.tick()
|
||||||
if request_counter == self.api.requests_sent:
|
if request_counter == self.api.requests_sent:
|
||||||
self.atlas_builder.do_work()
|
self.atlas_builder.do_work()
|
||||||
|
else:
|
||||||
|
print('nowork')
|
||||||
|
|
||||||
self.store.flush()
|
self.store.flush()
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
|
@ -251,6 +251,7 @@ class Store:
|
|||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
if time() < self.last_cleanup + self.cleanup_interval:
|
if time() < self.last_cleanup + self.cleanup_interval:
|
||||||
return
|
return
|
||||||
|
self.last_cleanup = time()
|
||||||
start_time = time()
|
start_time = time()
|
||||||
expired = list()
|
expired = list()
|
||||||
for t in self.data:
|
for t in self.data:
|
||||||
@ -262,7 +263,7 @@ class Store:
|
|||||||
|
|
||||||
del self.data[type(o)][o.symbol]
|
del self.data[type(o)][o.symbol]
|
||||||
dur = time() - start_time
|
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):
|
def flush(self):
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
|
Loading…
Reference in New Issue
Block a user