mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 10:31:42 +00:00
Fix issue where, if a shutdown request was sent while parsing static reference data, the program would continue parsing. #118
This commit is contained in:
@@ -22,6 +22,12 @@ class CQZoneData(LocalFileStaticDataProvider):
|
||||
cq_zone_data = geopandas.GeoDataFrame.from_features(json.load(f)["features"])
|
||||
for idx in cq_zone_data.index:
|
||||
prepare(cq_zone_data.at[idx, 'geometry'])
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to prepare the rest
|
||||
# of the data in this case
|
||||
if self.stop:
|
||||
break
|
||||
|
||||
DATA_STORE.cq_zone_data = cq_zone_data
|
||||
return True
|
||||
|
||||
|
||||
@@ -22,6 +22,12 @@ class ITUZoneData(LocalFileStaticDataProvider):
|
||||
itu_zone_data = geopandas.GeoDataFrame.from_features(json.load(f)["features"])
|
||||
for idx in itu_zone_data.index:
|
||||
prepare(itu_zone_data.at[idx, 'geometry'])
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to prepare the rest
|
||||
# of the data in this case
|
||||
if self.stop:
|
||||
break
|
||||
|
||||
DATA_STORE.itu_zone_data = itu_zone_data
|
||||
return True
|
||||
|
||||
|
||||
@@ -23,10 +23,18 @@ class K0SWE(FileDownloadStaticDataProvider):
|
||||
for dxcc in dxcc_list:
|
||||
dxcc_map[dxcc["entityCode"]] = dxcc
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest
|
||||
# of the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
# Add to data store
|
||||
for k, v in dxcc_map.items():
|
||||
DATA_STORE.dxcc_data[k] = v
|
||||
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
# Regenerate in-memory regex-to-DXCC-entity-code map.
|
||||
DATA_STORE.regenerateCallRegexToDXCCEntityMap()
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ class LocalFileStaticDataProvider(StaticDataProvider):
|
||||
def __init__(self, name, provider_config, path):
|
||||
super().__init__(name, provider_config)
|
||||
self._path = path
|
||||
self._stop = False
|
||||
|
||||
def start(self):
|
||||
logging.debug("Loading " + self.name + " static reference data from file.")
|
||||
@@ -29,7 +30,7 @@ class LocalFileStaticDataProvider(StaticDataProvider):
|
||||
logging.error("Exception in local file Static Data Provider (" + self.name + ")", e, exc_info=True)
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
self._stop = True
|
||||
|
||||
def _load_data(self, path):
|
||||
"""Load data from the given file path. Return true if successful, false otherwise."""
|
||||
|
||||
Reference in New Issue
Block a user