コード例 #1
0
ファイル: runner.py プロジェクト: pradal/cis_interface
 def signal_handler(self, sig, frame):
     r"""Terminate all drivers on interrrupt."""
     self.debug("Interrupt with signal %d", sig)
     now = backwards.clock_time()
     elapsed = now - self.interrupt_time
     self.debug('Elapsed time since last interrupt: %d s', elapsed)
     self.interrupt_time = now
     self.pprint(' ')
     self.pprint(80 * '*')
     if elapsed < 5:
         self.pprint('* %76s *' % 'Interrupted twice within 5 seconds: shutting down')
         self.pprint(80 * '*')
         # signal.siginterrupt(signal.SIGTERM, True)
         # signal.siginterrupt(signal.SIGINT, True)
         self.debug("Terminating models and closing all channels")
         self.terminate()
         self.pprint(80 * '*')
         # self.sleep(5)
         return 1
     else:
         self.pprint('* %76s *' % 'Interrupted: Displaying channel summary')
         self.pprint('* %76s *' % 'interrupt again (within 5 seconds) to exit')
         self.pprint(80 * '*')
         self.printStatus()
         self.pprint(80 * '*')
     self.debug('%d returns', sig)
コード例 #2
0
ファイル: tools.py プロジェクト: justinmcgrath/cis_interface
 def elapsed(self):
     r"""float: Total time that has elapsed since the start."""
     return backwards.clock_time() - self.start_time
コード例 #3
0
ファイル: tools.py プロジェクト: justinmcgrath/cis_interface
 def __init__(self, max_time, key=None):
     self.max_time = max_time
     self.start_time = backwards.clock_time()
     self.key = key