mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-11 07:01:41 +00:00
Improve slow startup times. #126
This commit is contained in:
@@ -17,6 +17,7 @@ class SIGRefDataProvider:
|
||||
self.last_update_time = datetime.min.replace(tzinfo=pytz.UTC)
|
||||
self.status = "Not Started" if self.enabled else "Disabled"
|
||||
self.reference_count = 0
|
||||
self._stop = False
|
||||
|
||||
|
||||
def start(self):
|
||||
@@ -26,14 +27,22 @@ class SIGRefDataProvider:
|
||||
|
||||
|
||||
def stop(self):
|
||||
"""Stop any threads and prepare for application shutdown"""
|
||||
"""Stop any threads and prepare for application shutdown. Subclasses should implement this method and call
|
||||
super()."""
|
||||
|
||||
raise NotImplementedError("Subclasses must implement this method")
|
||||
self._stop = True
|
||||
|
||||
def _add_data(self, new_data):
|
||||
"""Add all the provided reference data objects to the data store."""
|
||||
|
||||
for d in new_data:
|
||||
DATA_STORE.sigrefs[self.sig_name + ":" + d.id] = d
|
||||
|
||||
# For the big data sources, loading will take a few minutes. If we want to shut down the software neatly
|
||||
# within the first few minutes of startup, we need a way to abort this expensive process of filling up the
|
||||
# disk cache.
|
||||
if self._stop:
|
||||
break
|
||||
|
||||
self.reference_count = len(new_data)
|
||||
logging.info(f"Loaded %d references for %s into the data store.", self.reference_count, self.sig_name)
|
||||
|
||||
Reference in New Issue
Block a user