def _read_events(self, timeout=0): if self._event_reader is None: self._event_reader = htcondor.JobEventLog( self._event_log_path.as_posix()).events(timeout) for event in self._event_reader.events(timeout): # skip the late materialization submit event if event.proc == -1: continue job_id = JobID(event.cluster, event.proc) if event.type is htcondor.JobEventType.SUBMIT: self._jobid_to_taskid[job_id] = uuid.UUID( classad.unquote(event["LogNotes"])) # this lookup is safe because the SUBMIT event always comes first task_id = self._jobid_to_taskid[job_id] task = self.executor.tasks[task_id] if event.type is htcondor.JobEventType.JOB_HELD: # TODO: turn this into an appropriate exception on the future raise Exception("job held") new_status = JOB_EVENT_STATUS_TRANSITIONS.get(event.type, None) if new_status is not None: if new_status is self._task_statuses[task_id]: logger.warning( f"{task} of executor {self.executor} tried to transition into the state it is already in ({new_status})" ) else: self._task_statuses[task_id] = new_status if new_status is TaskStatus.COMPLETED: x = htio.load_objects(task.output_path) status = next(x) output = next(x) print(f"{task} finished with {status}, {output}") if status == "OK": task.future.set_result(output) elif status == "ERR": task.future.set_exception(output) else: raise Exception(f"bad task status {status}")
def test_quote(self): self.assertEquals(classad.quote("foo"), '"foo"') self.assertEquals(classad.quote('"foo'), '"\\"foo"') for i in ["foo", '"foo', '"\\"foo']: self.assertEquals(i, classad.unquote(classad.quote(i)))
def test_quote_unquote_is_symmetric(input): assert classad.unquote(classad.quote(input)) == input