Rate limit queue manager console messages

- Added last_status_print timestamp to QueueManager class
- Modified _process_queue to only print job status messages once every 10 seconds
- This prevents console spam from the queue manager when jobs are waiting for workers
parent 93413b21
......@@ -40,6 +40,7 @@ class QueueManager:
self.running = True
self.worker_thread = threading.Thread(target=self._process_queue, daemon=True)
self.worker_thread.start()
self.last_status_print = 0 # Timestamp of last status message
def submit_job(self, user_id: int, request_type: str, data: dict, priority: int = 0) -> int:
"""Submit a job to the queue."""
......@@ -136,12 +137,17 @@ class QueueManager:
if self.active_jobs < self.max_concurrent:
pending = get_pending_queue_items()
if pending:
current_time = time.time()
if current_time - self.last_status_print >= 10:
print(f"Found {len(pending)} pending job(s)", flush=True)
self.last_status_print = current_time
job = pending[0] # Get highest priority job
if self._can_start_job(job):
self._start_job(job)
else:
if current_time - self.last_status_print >= 10:
print(f"Job {job['id']} waiting for available workers", flush=True)
self.last_status_print = current_time
time.sleep(1) # Check every second
except Exception as e:
......
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