mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-05 18:11:41 +00:00
Improve use of URL cache #118
This commit is contained in:
@@ -7,7 +7,7 @@ from requests import ReadTimeout
|
||||
from requests.exceptions import ConnectionError, ConnectTimeout
|
||||
|
||||
from core.constants import HTTP_HEADERS
|
||||
from core.url_data_cache import URL_DATA_CACHE
|
||||
from core.url_data_cache import URLDataCache
|
||||
from sigrefdataproviders.sig_ref_data_provider import SIGRefDataProvider
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ class FileDownloadSIGRefDataProvider(SIGRefDataProvider):
|
||||
self._poll_interval = poll_interval
|
||||
self._thread = None
|
||||
self._stop_event = Event()
|
||||
self._url_data_cache = URLDataCache("sigrefdata-" + sig_name)
|
||||
|
||||
def start(self):
|
||||
# Fire off the polling thread. It will poll immediately on startup, then sleep for poll_interval between
|
||||
@@ -44,7 +45,7 @@ class FileDownloadSIGRefDataProvider(SIGRefDataProvider):
|
||||
# Request data from API. Use the data cache (with a TTL of 1 day) here, not as the main mechanism for
|
||||
# caching, but just so continual restarts of the software during testing don't hammer the servers.
|
||||
logging.debug("Downloading " + self.sig_name + " SIG ref data...")
|
||||
http_response = URL_DATA_CACHE.get(self._url, headers=HTTP_HEADERS)
|
||||
http_response = self._url_data_cache.get(self._url, headers=HTTP_HEADERS)
|
||||
# Check response code was good
|
||||
if http_response.ok:
|
||||
# Pass off to the subclass for processing
|
||||
|
||||
Reference in New Issue
Block a user