logging.debug("Found job %s in memcache", job_id)
return job
+ job = self._LoadJobFromDisk(job_id)
+
+ self._memcache[job_id] = job
+ logging.debug("Added job %s to the cache", job_id)
+ return job
+
+ def _LoadJobFromDisk(self, job_id):
+ """Load the given job file from disk.
+
+ Given a job file, read, load and restore it in a _QueuedJob format.
+
+ @type job_id: string
+ @param job_id: job identifier
+ @rtype: L{_QueuedJob} or None
+ @return: either None or the job object
+
+ """
filepath = self._GetJobPath(job_id)
logging.debug("Loading job from %s", filepath)
try:
raw_data = utils.ReadFile(filepath)
- except IOError, err:
+ except EnvironmentError, err:
if err.errno in (errno.ENOENT, ):
return None
raise
- data = serializer.LoadJson(raw_data)
-
try:
+ data = serializer.LoadJson(raw_data)
job = _QueuedJob.Restore(self, data)
except Exception, err: # pylint: disable-msg=W0703
new_path = self._GetArchivedJobPath(job_id)
self._RenameFilesUnlocked([(filepath, new_path)])
return None
- self._memcache[job_id] = job
- logging.debug("Added job %s to the cache", job_id)
return job
def _GetJobsUnlocked(self, job_ids):