Revision 162c8636 lib/jqueue.py
b/lib/jqueue.py | ||
---|---|---|
938 | 938 |
logging.debug("Found job %s in memcache", job_id) |
939 | 939 |
return job |
940 | 940 |
|
941 |
job = self._LoadJobFromDisk(job_id) |
|
942 |
|
|
943 |
self._memcache[job_id] = job |
|
944 |
logging.debug("Added job %s to the cache", job_id) |
|
945 |
return job |
|
946 |
|
|
947 |
def _LoadJobFromDisk(self, job_id): |
|
948 |
"""Load the given job file from disk. |
|
949 |
|
|
950 |
Given a job file, read, load and restore it in a _QueuedJob format. |
|
951 |
|
|
952 |
@type job_id: string |
|
953 |
@param job_id: job identifier |
|
954 |
@rtype: L{_QueuedJob} or None |
|
955 |
@return: either None or the job object |
|
956 |
|
|
957 |
""" |
|
941 | 958 |
filepath = self._GetJobPath(job_id) |
942 | 959 |
logging.debug("Loading job from %s", filepath) |
943 | 960 |
try: |
944 | 961 |
raw_data = utils.ReadFile(filepath) |
945 |
except IOError, err:
|
|
962 |
except EnvironmentError, err:
|
|
946 | 963 |
if err.errno in (errno.ENOENT, ): |
947 | 964 |
return None |
948 | 965 |
raise |
949 | 966 |
|
950 |
data = serializer.LoadJson(raw_data) |
|
951 |
|
|
952 | 967 |
try: |
968 |
data = serializer.LoadJson(raw_data) |
|
953 | 969 |
job = _QueuedJob.Restore(self, data) |
954 | 970 |
except Exception, err: # pylint: disable-msg=W0703 |
955 | 971 |
new_path = self._GetArchivedJobPath(job_id) |
... | ... | |
962 | 978 |
self._RenameFilesUnlocked([(filepath, new_path)]) |
963 | 979 |
return None |
964 | 980 |
|
965 |
self._memcache[job_id] = job |
|
966 |
logging.debug("Added job %s to the cache", job_id) |
|
967 | 981 |
return job |
968 | 982 |
|
969 | 983 |
def _GetJobsUnlocked(self, job_ids): |
Also available in: Unified diff