Refactor of caching & data storage part 2 #118

This commit is contained in:
Ian Renton
2026-07-31 15:18:23 +01:00
parent d26ddff7d1
commit 818fd2d504
17 changed files with 186 additions and 243 deletions
+2 -12
View File
@@ -2,7 +2,7 @@ from datetime import datetime
import pytz
from core.config import MAX_SPOT_AGE
from core.data_store import DATA_STORE
class SpotProvider:
@@ -16,14 +16,7 @@ class SpotProvider:
self.last_update_time = datetime.min.replace(tzinfo=pytz.UTC)
self.last_spot_time = datetime.min.replace(tzinfo=pytz.UTC)
self.status = "Not Started" if self.enabled else "Disabled"
self._spots = None
self._web_server = None
def setup(self, spots, web_server):
"""Set up the provider, e.g. giving it the spot list to work from"""
self._spots = spots
self._web_server = web_server
self._spots = DATA_STORE.spots
def start(self):
"""Start the provider. This should return immediately after spawning threads to access the remote resources"""
@@ -60,9 +53,6 @@ class SpotProvider:
def _add_spot(self, spot):
if not spot.expired():
self._spots.set(spot.id, spot)
# Ping the web server in case we have any SSE connections that need to see this immediately
if self._web_server:
self._web_server.notify_new_spot(spot)
def stop(self):
"""Stop any threads and prepare for application shutdown"""