Fix issue where dead jobs try to be started after restarting

This commit is contained in:
Brett Williams
2023-05-27 21:53:34 -05:00
parent e300024e2b
commit 528c802fe2
2 changed files with 8 additions and 3 deletions

View File

@@ -133,6 +133,7 @@ class RenderQueue:
scheduled = cls.jobs_with_status(RenderStatus.SCHEDULED, priority_sorted=True) scheduled = cls.jobs_with_status(RenderStatus.SCHEDULED, priority_sorted=True)
for job in scheduled: for job in scheduled:
if job.scheduled_start <= datetime.now(): if job.scheduled_start <= datetime.now():
logger.debug(f"Starting scheduled job: {job}")
cls.start_job(job) cls.start_job(job)
if cls.last_saved_counts != cls.job_counts(): if cls.last_saved_counts != cls.job_counts():

View File

@@ -85,10 +85,12 @@ class ScheduledJob(Base):
worker_status = RenderStatus(self.worker_data()['status']) worker_status = RenderStatus(self.worker_data()['status'])
if hasattr(self, 'worker_object'): if hasattr(self, 'worker_object'):
if self.scheduled_start and worker_status == RenderStatus.NOT_STARTED: if self.scheduled_start and worker_status == RenderStatus.NOT_STARTED:
return RenderStatus.SCHEDULED worker_status = RenderStatus.SCHEDULED
else: else:
if worker_status == RenderStatus.RUNNING: if worker_status == RenderStatus.RUNNING:
return RenderStatus.ERROR worker_status = RenderStatus.ERROR
elif worker_status == RenderStatus.NOT_STARTED:
worker_status = RenderStatus.CANCELLED
except Exception as e: except Exception as e:
logger.error(f"Exception fetching render status: {e}") logger.error(f"Exception fetching render status: {e}")
worker_status = RenderStatus.UNDEFINED worker_status = RenderStatus.UNDEFINED
@@ -142,7 +144,9 @@ class ScheduledJob(Base):
def file_list(self): def file_list(self):
job_dir = os.path.dirname(self.output_path) job_dir = os.path.dirname(self.output_path)
return glob.glob(os.path.join(job_dir, '*')) file_list = glob.glob(os.path.join(job_dir, '*'))
file_list.sort()
return file_list
def log_path(self): def log_path(self):
return os.path.join(os.path.dirname(self.input_path), self.name + '.log') return os.path.join(os.path.dirname(self.input_path), self.name + '.log')