mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-03-15 12:24:29 +00:00
Attempt to fix CPU utilisation bug by preventing the heartbeat callback leak in the SSE stream handlers and replacing Timer-based with Event-based threads. Also compiled regexes in advance for DXCC callsign lookups for efficiency, and fixed my misunderstanding of what Queue.empty() does
This commit is contained in:
@@ -101,6 +101,10 @@ class LookupHelper:
|
||||
else:
|
||||
logging.error("Could not download DXCC data, flags and similar data may be missing!")
|
||||
|
||||
# Precompile regex matches for DXCCs to improve efficiency when iterating through them
|
||||
for dxcc in self.DXCC_DATA.values():
|
||||
dxcc["_prefixRegexCompiled"] = re.compile(dxcc["prefixRegex"])
|
||||
|
||||
# Download the cty.plist file from country-files.com on first startup. The pyhamtools lib can actually download and use
|
||||
# this itself, but it's occasionally offline which causes it to throw an error. By downloading it separately, we can
|
||||
# catch errors and handle them, falling back to a previous copy of the file in the cache, and we can use the
|
||||
@@ -559,7 +563,7 @@ class LookupHelper:
|
||||
# Utility method to get generic DXCC data from our lookup table, if we can find it
|
||||
def get_dxcc_data_for_callsign(self, call):
|
||||
for entry in self.DXCC_DATA.values():
|
||||
if re.match(entry["prefixRegex"], call):
|
||||
if entry["_prefixRegexCompiled"].match(call):
|
||||
return entry
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user