def run_exp(self): self.__check_system() succ = False try: self.__setup() try: self.__run_tasks() self.log("Saving results in %s" % self.finished_dir) succ = True except: traceback.print_exc() self.__kill_all() raise ExperimentFailed(self.name) finally: self.__teardown() finally: self.log("Switching to Linux scheduler") # Give the tasks 10 seconds to finish before bailing start = time.time() while lu.all_tasks() > 0: if time.time() - start < 10.0: raise SystemCorrupted("%d tasks still running!" % lu.all_tasks()) lu.switch_scheduler("Linux") if succ: self.__save_results() self.log("Experiment done!")
def __setup(self): self.__make_dirs() self.__assign_executable_cwds() self.__setup_tracers() self.log("Writing %d proc entries" % len(self.proc_entries)) map(methodcaller('write_proc'), self.proc_entries) self.log("Starting %d regular tracers" % len(self.regular_tracers)) map(methodcaller('start_tracing'), self.regular_tracers) time.sleep(1) self.log("Switching to %s" % self.scheduler) lu.switch_scheduler(self.scheduler) time.sleep(1) self.exec_out = open('%s/exec-out.txt' % self.working_dir, 'w') self.exec_err = open('%s/exec-err.txt' % self.working_dir, 'w') def set_out(executable): executable.stdout_file = self.exec_out executable.stderr_file = self.exec_err map(set_out, self.executables)
def setup(self): self.log("Writing %d proc entries" % len(self.proc_entries)) map(methodcaller('write_proc'), self.proc_entries) self.log("Switching to %s" % self.scheduler) lu.switch_scheduler(self.scheduler) self.log("Starting %d tracers" % len(self.tracers)) map(methodcaller('start_tracing'), self.tracers) self.exec_out = open('%s/exec-out.txt' % self.working_dir, 'w') self.exec_err = open('%s/exec-err.txt' % self.working_dir, 'w') def set_out(executable): executable.stdout_file = self.exec_out executable.stderr_file = self.exec_err map(set_out, self.executables)
def __to_linux(self): msgs = [] sched = lu.scheduler() if sched != "Linux": self.log("Switching back to Linux scheduler") try: lu.switch_scheduler("Linux") except: msgs += ["Scheduler is %s, cannot switch to Linux!" % sched] running = lu.all_tasks() if running: msgs += ["%d real-time tasks still running!" % running] if msgs: raise SystemCorrupted("\n".join(msgs))
def run_exp(self): succ = False try: self.setup() try: self.__run_tasks() self.log("Saving results in %s" % self.finished_dir) succ = True finally: self.teardown() finally: self.log("Switching to Linux scheduler") lu.switch_scheduler("Linux") if succ: self.__save_results() self.log("Experiment done!")