Skip to content
Snippets Groups Projects
Commit 94ed59a5 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix job queue behaviour when loading jobs

Currently, if loading a job fails, the job queue code raises an
exception and prevents the proper processing of the jobs in the queue.
We change this so that unparseable jobs are instead archived (if not
already).

Reviewed-by: imsnah
parent d5927e48
No related branches found
No related tags found
No related merge requests found
...@@ -382,6 +382,10 @@ class JobQueue(object): ...@@ -382,6 +382,10 @@ class JobQueue(object):
self.acquire() self.acquire()
try: try:
for job in self._GetJobsUnlocked(None): for job in self._GetJobsUnlocked(None):
# a failure in loading the job can cause 'None' to be returned
if job is None:
continue
status = job.CalcStatus() status = job.CalcStatus()
if status in (constants.JOB_STATUS_QUEUED, ): if status in (constants.JOB_STATUS_QUEUED, ):
...@@ -553,7 +557,19 @@ class JobQueue(object): ...@@ -553,7 +557,19 @@ class JobQueue(object):
finally: finally:
fd.close() fd.close()
job = _QueuedJob.Restore(self, data) try:
job = _QueuedJob.Restore(self, data)
except Exception, err:
new_path = self._GetArchivedJobPath(job_id)
if filepath == new_path:
# job already archived (future case)
logging.exception("Can't parse job %s", job_id)
else:
# non-archived case
logging.exception("Can't parse job %s, will archive.", job_id)
self._RenameFileUnlocked(filepath, new_path)
return None
self._memcache[job_id] = job self._memcache[job_id] = job
logging.debug("Added job %s to the cache", job_id) logging.debug("Added job %s to the cache", job_id)
return job return job
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment