def wait(self, tid): """Wait for the task to finish.""" assert(self.finished(tid)) params = self._params[tid] popsno = self._popsno[tid] index = popsno - 1 tmpInput = "/tmp/" + params.name + "Input." + str(popsno) tmpOutput = "/tmp/" + params.name + "Output." + str(popsno) output_dict = {} for adverb in params.output_list: # Need to parse whole file each time as order not specified out_file = open(tmpOutput, mode='r') output_dict[adverb] = self.__read_adverb(params, out_file, adverb) out_file.close() if os.access(tmpInput, os.F_OK): os.unlink(tmpInput) # Remove input file. if os.access(tmpOutput, os.F_OK): os.unlink(tmpOutput) # Remove output file. _free_popsno(popsno) del self._params[tid] del self._popsno[tid] Task.wait(self, tid) return output_dict
def wait(self, tid): """Wait for the task to finish.""" assert (self.finished(tid)) params = self._params[tid] popsno = self._popsno[tid] index = popsno - 1 tmpInput = "/tmp/" + params.name + "Input." + str(popsno) tmpOutput = "/tmp/" + params.name + "Output." + str(popsno) output_dict = {} for adverb in params.output_list: # Need to parse whole file each time as order not specified out_file = open(tmpOutput, mode='r') output_dict[adverb] = self.__read_adverb(params, out_file, adverb) out_file.close() if os.access(tmpInput, os.F_OK): os.unlink(tmpInput) # Remove input file. if os.access(tmpOutput, os.F_OK): os.unlink(tmpOutput) # Remove output file. _free_popsno(popsno) del self._params[tid] del self._popsno[tid] Task.wait(self, tid) return output_dict
def wait(self, tid): """Wait for the task to finish. Waits for Obit task to finishes, reads the task output parameter file and deleted tas input and output parameter file. Returns output parameters in adictionary. tid = Task id in pid table of process """ assert (self.finished(tid)) params = self._params[tid] popsno = self._popsno[tid] index = popsno - 1 tmpInput = "/tmp/" + params.name + "Input." + str(popsno) tmpOutput = "/tmp/" + params.name + "Output." + str(popsno) output_dict = {} for adverb in params.output_list: out_file = open(tmpOutput, mode='r') # Need to parse whole file each time as order not specified val = self.__read_adverb(params, out_file, adverb) output_dict[adverb] = val out_file.close() _free_popsno(popsno) # Release Pops number if os.access(tmpInput, os.F_OK): os.unlink(tmpInput) # Remove input file. if os.access(tmpOutput, os.F_OK): os.unlink(tmpOutput) # Remove output file. # Check if terminated normally retCode = output_dict["retCode"] if retCode != 0: msg = "Task '%s' returns '%d'" % (params.name, retCode) raise RuntimeError(msg) del self._params[tid] del self._popsno[tid] Task.wait(self, tid) return output_dict
def wait(self, tid): """Wait for the task to finish. When task returns, the output parameters are parser from the TD file. Returns output parameters in adictionary. tid = Task id in pid table of process """ assert (self.finished(tid)) params = self._params[tid] popsno = self._popsno[tid] index = popsno - 1 td_name = os.environ['DA00'] + '/TDD000004;' try: td_file = open(td_name, mode='rb') td_file.seek(index * 20 + 8) (result, ) = struct.unpack('i', td_file.read(4)) if result != 0: msg = "Task '%s' returns '%d'" % (params.name, result) raise RuntimeError(msg) td_file.seek(1024 + index * 4096 + 40) output_dict = {} for adverb in params.output_list: output_dict[adverb] = self.__read_adverb( params, td_file, adverb) td_file.close() finally: _free_popsno(popsno) pass del self._params[tid] del self._popsno[tid] del self._userno[tid] del self._msgno[tid] Task.wait(self, tid) return output_dict
def wait(self, tid): """Wait for the task to finish.""" assert(self.finished(tid)) params = self._params[tid] popsno = self._popsno[tid] index = popsno - 1 td_name = os.environ['DA00'] + '/TDD000004;' try: td_file = open(td_name, mode='rb') td_file.seek(index * 20 + 8) (result,) = struct.unpack('i', td_file.read(4)) if result != 0: msg = "Task '%s' returns '%d'" % (params.name, result) raise RuntimeError, msg td_file.seek(1024 + index * 4096 + 40) output_dict = {} for adverb in params.output_list: output = self.__read_adverb(params, td_file, adverb) output_dict[adverb] = output continue td_file.close() finally: _free_popsno(popsno) pass del self._params[tid] del self._popsno[tid] del self._userno[tid] del self._msgno[tid] Task.wait(self, tid) return output_dict
def wait(self, tid): """Wait for the script to finish. Waits until script is finished tid = Script id in pid table of process """ assert(self.finished(tid)) # Cleanup popsno = self._popsno[tid] _free_popsno(self._popsno[tid]) del self._popsno[tid] del self._userno[tid] del self._msgno[tid] # wait Task.wait(self, tid) # Delete Script text file sc_name = "/tmp/" + self.name+ "Script." + str(popsno)+".py" if os.access(sc_name, os.F_OK): os.unlink(sc_name) return True # Return something other than None