2060 def _update_result_status(self, condor_q_output):
2061 """
2062 In order to be slightly more efficient we pass in a previous call to condor_q to see if it can work.
2063 If it is there we update the job's status. If not we are forced to start calling condor_q and, if needed,
2064 ``condor_history``, etc.
2065
2066 Parameters:
2067 condor_q_output (dict): The JSON output of a previous call to `HTCondor.condor_q` which we can reuse to find the
2068 status of this job if it was active when that command ran.
2069 """
2070 B2DEBUG(29, f"Calling {self.job}.result._update_result_status()")
2071 jobs_info = []
2072 for job_record in condor_q_output["JOBS"]:
2073 job_id = job_record["GlobalJobId"].split("#")[1]
2074 if job_id == self.job_id:
2075 B2DEBUG(29, f"Found {self.job_id} in condor_q_output.")
2076 jobs_info.append(job_record)
2077
2078
2079 if not jobs_info:
2080 try:
2081 exit_code = self.get_exit_code_from_file()
2082 except FileNotFoundError:
2083 waiting_time = datetime.now() - self.exit_code_file_initial_time
2084 if self.time_to_wait_for_exit_code_file > waiting_time:
2085 B2ERROR(f"Exit code file for {self.job} missing and we can't wait longer. Setting exit code to 1.")
2086 exit_code = 1
2087 else:
2088 B2WARNING(f"Exit code file for {self.job} missing, will wait longer.")
2089 return
2090 if exit_code:
2091 jobs_info = [{"JobStatus": 6, "HoldReason": None}]
2092 else:
2093 jobs_info = [{"JobStatus": 4, "HoldReason": None}]
2094
2095
2096 if not jobs_info:
2097 jobs_info = HTCondor.condor_q(job_id=self.job_id, class_ads=["JobStatus", "HoldReason"])["JOBS"]
2098
2099
2100
2101 if not jobs_info:
2102 try:
2103 jobs_info = HTCondor.condor_history(job_id=self.job_id, class_ads=["JobStatus", "HoldReason"])["JOBS"]
2104 except KeyError:
2105 hold_reason = "No Reason Known"
2106
2107
2108 if not jobs_info:
2109 jobs_info = [{"JobStatus": 6, "HoldReason": None}]
2110
2111 job_info = jobs_info[0]
2112 backend_status = job_info["JobStatus"]
2113
2114 if backend_status == 5:
2115 hold_reason = job_info.get("HoldReason", None)
2116 B2WARNING(f"{self.job} on hold because of {hold_reason}. Keep waiting.")
2117 backend_status = 2
2118 try:
2119 new_job_status = self.backend_code_to_status[backend_status]
2120 except KeyError as err:
2121 raise BackendError(f"Unidentified backend status found for {self.job}: {backend_status}") from err
2122 if new_job_status != self.job.status:
2123 self.job.status = new_job_status
2124
2125 @classmethod