Fix list index out of range error in worker_analysis.py when msg_id lacks '_'

parent 7fe399c3
...@@ -60,7 +60,8 @@ class BackgroundPing: ...@@ -60,7 +60,8 @@ class BackgroundPing:
self.comm = comm self.comm = comm
self.running = False self.running = False
self.thread = None self.thread = None
self.job_id_int = int(job_id.split('_')[1]) if job_id else None parts = job_id.split('_') if job_id else []
self.job_id_int = int(parts[1]) if len(parts) > 1 else 0
def start(self): def start(self):
"""Start the background ping thread.""" """Start the background ping thread."""
...@@ -231,7 +232,8 @@ def check_job_cancelled(job_id): ...@@ -231,7 +232,8 @@ def check_job_cancelled(job_id):
def analyze_media(media_path, prompt, model_path, interval=10, job_id=None, comm=None): def analyze_media(media_path, prompt, model_path, interval=10, job_id=None, comm=None):
"""Analyze media using dynamic model loading.""" """Analyze media using dynamic model loading."""
job_id_int = int(job_id.split('_')[1]) if job_id else None parts = job_id.split('_') if job_id else []
job_id_int = int(parts[1]) if len(parts) > 1 else 0
if get_debug(): if get_debug():
log_message(f"DEBUG: Starting analyze_media for job {job_id_int}, media_path={media_path}") log_message(f"DEBUG: Starting analyze_media for job {job_id_int}, media_path={media_path}")
...@@ -564,7 +566,8 @@ def worker_process(backend_type: str): ...@@ -564,7 +566,8 @@ def worker_process(backend_type: str):
model_path = data.get('model_path', 'Qwen/Qwen2.5-VL-7B-Instruct') model_path = data.get('model_path', 'Qwen/Qwen2.5-VL-7B-Instruct')
interval = data.get('interval', 10) interval = data.get('interval', 10)
job_id = message.msg_id # Use message ID for job identification job_id = message.msg_id # Use message ID for job identification
job_id_int = int(message.msg_id.split('_')[1]) # Extract integer job ID parts = message.msg_id.split('_')
job_id_int = int(parts[1]) if len(parts) > 1 else 0 # Extract integer job ID
log_message(f"PROGRESS: Job {job_id_int} accepted - Starting analysis") log_message(f"PROGRESS: Job {job_id_int} accepted - Starting analysis")
if get_debug(): if get_debug():
log_message(f"DEBUG: Starting analysis of {media_path} with model {model_path} for job {job_id}") log_message(f"DEBUG: Starting analysis of {media_path} with model {model_path} for job {job_id}")
......
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