def _run(self): try: self.state = 'run' for target in auto_focus.targets.keys(): auto_focus.periodic_focus = False while auto_focus.state != 'idle': threading.currentThread().stop_request.wait(1.0) if threading.currentThread().stop_request.isSet(): break auto_focus.current_target = target auto_focus.submit() auto_focus.periodic_focus = True odmr = me.odmr.ODMR() odmr.stop_time = 60 odmr.submit() while odmr.state != 'done': threading.currentThread().stop_request.wait(1.0) if threading.currentThread().stop_request.isSet(): break odmr.save(timestamp() + '_' + target + '_odmr.pys') self.state = 'done' finally: self.state = 'error'
def start(self): """Start the process loop in a thread.""" if self.thread.is_alive(): return self.thread = StoppableThread(target=self.run, name=self.__class__.__name__ + timestamp()) self.thread.start()
def start(self): """Start the process loop in a thread.""" if self.thread.is_alive(): return logging.getLogger().info('Starting Job Manager.') self.thread = StoppableThread(target=self._process, name=self.__class__.__name__ + timestamp()) self.thread.start()
def _run(self): try: self.state = 'run' job = self.job if self.filename is None: filename = str(job) else: filename = self.filename if self.timestamp: filename = timestamp() + '_' + filename job.save(filename) finally: self.state = 'idle'