mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-03-15 12:24:29 +00:00
Bulk convert comments above classes/functions/methods into proper docstrings
This commit is contained in:
@@ -6,11 +6,12 @@ from time import sleep
|
||||
import pytz
|
||||
|
||||
|
||||
# Provides a timed cleanup of the spot list.
|
||||
class CleanupTimer:
|
||||
"""Provides a timed cleanup of the spot list."""
|
||||
|
||||
# Constructor
|
||||
def __init__(self, spots, alerts, web_server, cleanup_interval):
|
||||
"""Constructor"""
|
||||
|
||||
self.spots = spots
|
||||
self.alerts = alerts
|
||||
self.web_server = web_server
|
||||
@@ -20,21 +21,24 @@ class CleanupTimer:
|
||||
self.status = "Starting"
|
||||
self._stop_event = Event()
|
||||
|
||||
# Start the cleanup timer
|
||||
def start(self):
|
||||
"""Start the cleanup timer"""
|
||||
|
||||
self._thread = Thread(target=self._run, daemon=True)
|
||||
self._thread.start()
|
||||
|
||||
# Stop any threads and prepare for application shutdown
|
||||
def stop(self):
|
||||
"""Stop any threads and prepare for application shutdown"""
|
||||
|
||||
self._stop_event.set()
|
||||
|
||||
def _run(self):
|
||||
while not self._stop_event.wait(timeout=self.cleanup_interval):
|
||||
self._cleanup()
|
||||
|
||||
# Perform cleanup and reschedule next timer
|
||||
def _cleanup(self):
|
||||
"""Perform cleanup and reschedule next timer"""
|
||||
|
||||
try:
|
||||
# Perform cleanup via letting the data expire
|
||||
self.spots.expire()
|
||||
|
||||
Reference in New Issue
Block a user