Fix rate limiting logic for console messages

- Calculate should_print_status once per loop iteration instead of updating timestamp inside the loop
- This ensures consistent rate limiting where all job status messages are either printed together or not at all
parent 958814d8
......@@ -1060,7 +1060,9 @@ class ClusterMaster:
conn.close()
current_time = time.time()
if jobs and (current_time - self.last_job_status_print) >= 10:
should_print_status = jobs and (current_time - self.last_job_status_print) >= 10
if should_print_status:
print(f"Found {len(jobs)} pending job(s)")
self.last_job_status_print = current_time
......@@ -1068,9 +1070,8 @@ class ClusterMaster:
job = dict(job_row)
job['data'] = json.loads(job['data']) if job['data'] else None
process_type = 'analysis' if job['request_type'] == 'analyze' else ('training' if job['request_type'] == 'train' else job['request_type'])
if (current_time - self.last_job_status_print) >= 10:
if should_print_status:
print(f"Job {job['id']} waiting for available workers")
self.last_job_status_print = current_time
worker_key = self.select_worker_for_job(process_type, job['data'].get('model_path', 'Qwen/Qwen2.5-VL-7B-Instruct'), job['data'])
if worker_key:
job_id = self.assign_job_to_worker(worker_key, job['data'])
......
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