Let sacct handle queries for expired jobs in slurm job interface.
@@ -142,13 +142,17 @@ class SlurmJobManager(BaseJobManager):
code, out, err = interruptable_popen(cmd, shell=True, executable="/bin/bash",
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ # special case: when the id of a single yet expired job is queried, squeue responds with an
+ # error (exit code != 0), so as a workaround, consider these cases as an empty result
+ if code != 0 and "invalid job id specified" in err.lower():
+ code = 0
+ query_data = {}
+
+ else:
# handle errors
if code != 0:
- if "Invalid job id specified" in err:
- return {id: self.job_status_dict(job_id=id, status=self.FAILED, error="slurm doesn't know about this job")
- for id in job_id}
- elif silent:
- return None # FIXME: doing this seems to break BaseRemoteWorkflowProxy.poll
+ if silent:
+ return None
else:
raise Exception("queue query of slurm job(s) '{}' failed with code {}:"
"\n{}".format(job_id, code, err))
