Revision aebd0e4e lib/jqueue.py
b/lib/jqueue.py | ||
---|---|---|
2309 | 2309 |
""" |
2310 | 2310 |
logging.info("Cancelling job %s", job_id) |
2311 | 2311 |
|
2312 |
return self._ModifyJobUnlocked(job_id, lambda job: job.Cancel()) |
|
2313 |
|
|
2314 |
def _ModifyJobUnlocked(self, job_id, mod_fn): |
|
2315 |
"""Modifies a job. |
|
2316 |
|
|
2317 |
@type job_id: int |
|
2318 |
@param job_id: Job ID |
|
2319 |
@type mod_fn: callable |
|
2320 |
@param mod_fn: Modifying function, receiving job object as parameter, |
|
2321 |
returning tuple of (status boolean, message string) |
|
2322 |
|
|
2323 |
""" |
|
2312 | 2324 |
job = self._LoadJobUnlocked(job_id) |
2313 | 2325 |
if not job: |
2314 | 2326 |
logging.debug("Job %s not found", job_id) |
2315 | 2327 |
return (False, "Job %s not found" % job_id) |
2316 | 2328 |
|
2317 |
assert job.writable, "Can't cancel read-only job"
|
|
2318 |
assert not job.archived, "Can't cancel archived job"
|
|
2329 |
assert job.writable, "Can't modify read-only job"
|
|
2330 |
assert not job.archived, "Can't modify archived job"
|
|
2319 | 2331 |
|
2320 |
(success, msg) = job.Cancel()
|
|
2332 |
(success, msg) = mod_fn(job)
|
|
2321 | 2333 |
|
2322 | 2334 |
if success: |
2323 | 2335 |
# If the job was finalized (e.g. cancelled), this is the final write |
Also available in: Unified diff