Simplify distributed worker check to use connected clients

parent cc35fff0
...@@ -122,13 +122,9 @@ class QueueManager: ...@@ -122,13 +122,9 @@ class QueueManager:
def _has_distributed_worker(self, process_type: str) -> bool: def _has_distributed_worker(self, process_type: str) -> bool:
"""Check if there is a distributed worker available for the process type.""" """Check if there is a distributed worker available for the process type."""
from .database import get_db_connection from .database import get_connected_cluster_clients
conn = get_db_connection() clients = get_connected_cluster_clients()
cursor = conn.cursor() return len(clients) > 0
cursor.execute('SELECT id FROM cluster_processes WHERE process_name LIKE ? AND status = ?', (f'{process_type}%', 'active'))
result = cursor.fetchone()
conn.close()
return result is not None
def _process_queue(self) -> None: def _process_queue(self) -> None:
"""Background thread to process queued jobs.""" """Background thread to process queued jobs."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment