From 6210fa17d876de0988b6e4f164ca6a870bbba41e Mon Sep 17 00:00:00 2001 From: Josema Camacho Date: Thu, 19 Mar 2026 12:58:48 +0100 Subject: [PATCH] refactor(api): harden stale attack paths cleanup with ping cache, error handling and idempotent migration - Passing ruff --- api/src/backend/tasks/jobs/attack_paths/cleanup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api/src/backend/tasks/jobs/attack_paths/cleanup.py b/api/src/backend/tasks/jobs/attack_paths/cleanup.py index 14be492954..c88ddaaadd 100644 --- a/api/src/backend/tasks/jobs/attack_paths/cleanup.py +++ b/api/src/backend/tasks/jobs/attack_paths/cleanup.py @@ -91,9 +91,7 @@ def cleanup_stale_attack_paths_scans() -> dict: def _is_worker_alive(worker: str) -> bool: """Ping a specific Celery worker. Returns `True` if it responds or on error.""" try: - response = current_app.control.inspect( - destination=[worker], timeout=1.0 - ).ping() + response = current_app.control.inspect(destination=[worker], timeout=1.0).ping() return response is not None and worker in response except Exception: logger.exception(f"Failed to ping worker {worker}, treating as alive")