Improve expired spot handling and efficiency of handling expired spots during web requests.

This commit is contained in:
Ian Renton
2025-11-29 16:12:44 +00:00
parent 3da8c80ad6
commit 8a4f23ac72
6 changed files with 64 additions and 49 deletions

View File

@@ -29,12 +29,15 @@ class CleanupTimer:
# Perform cleanup and reschedule next timer
def cleanup(self):
try:
# Perform cleanup
# Perform cleanup via letting the data expire
self.spots.expire()
self.alerts.expire()
# Alerts can persist in the system for a while, so we want to explicitly clean up any alerts that have
# expired
# Explicitly clean up any spots and alerts that have expired
for id in list(self.spots.iterkeys()):
spot = self.spots[id]
if spot.expired():
self.spots.delete(id)
for id in list(self.alerts.iterkeys()):
alert = self.alerts[id]
if alert.expired():