refactor: govern background job lifecycle
This commit is contained in:
@@ -128,14 +128,19 @@ class DashboardService(
|
||||
profile_supplier=self._resolved_llm_profile,
|
||||
)
|
||||
self.screener.ensure_builtin_strategies()
|
||||
self._background_stop = threading.Event()
|
||||
self._background_thread = self.jobs.start_scheduler(
|
||||
|
||||
def start_background_jobs(self) -> threading.Thread:
|
||||
return self.jobs.start_scheduler(
|
||||
self._background_refresh_tick,
|
||||
self._background_stop,
|
||||
interval_seconds=5,
|
||||
initial_delay_seconds=3,
|
||||
)
|
||||
|
||||
def stop_background_jobs(self, timeout_seconds: float = 5) -> bool:
|
||||
scheduler_stopped = self.jobs.stop_scheduler(timeout_seconds)
|
||||
workers_stopped = self.jobs.wait_for_idle(timeout_seconds)
|
||||
return scheduler_stopped and workers_stopped
|
||||
|
||||
|
||||
def _load_system_credentials(self, environment: dict[str, str]) -> dict[str, Any]:
|
||||
encrypted = self.database.get_system_setting("credentials")
|
||||
|
||||
Reference in New Issue
Block a user