From 606e4985546b1f995c6cb3aded3d0faada0c5703 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Mon, 27 May 2019 11:03:04 +0200 Subject: [PATCH] ReviewBot: Simplify the !interval case We only want to run the workfunc() and that's it --- ReviewBot.py | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/ReviewBot.py b/ReviewBot.py index 7b05a9d2..d5a07b58 100644 --- a/ReviewBot.py +++ b/ReviewBot.py @@ -845,10 +845,12 @@ class CommandLineInterface(cmdln.Cmdln): class ExTimeout(Exception): """raised on timeout""" - if interval: - def alarm_called(nr, frame): - raise ExTimeout() - signal.signal(signal.SIGALRM, alarm_called) + if not interval: + return workfunc() + + def alarm_called(nr, frame): + raise ExTimeout() + signal.signal(signal.SIGALRM, alarm_called) while True: try: @@ -856,31 +858,27 @@ class CommandLineInterface(cmdln.Cmdln): except Exception as e: self.logger.exception(e) - if interval: - if os.isatty(0): - self.logger.info("sleeping %d minutes. Press enter to check now ..."%interval) - signal.alarm(interval*60) - try: - input() - except ExTimeout: - pass - signal.alarm(0) - self.logger.info("recheck at %s"%datetime.datetime.now().isoformat()) - else: - self.logger.info("sleeping %d minutes." % interval) - time.sleep(interval * 60) + if os.isatty(0): + self.logger.info("sleeping %d minutes. Press enter to check now ..."%interval) + signal.alarm(interval*60) + try: + input() + except ExTimeout: + pass + signal.alarm(0) + self.logger.info("recheck at %s"%datetime.datetime.now().isoformat()) + else: + self.logger.info("sleeping %d minutes." % interval) + time.sleep(interval * 60) - # Reset all memoize session caches which are designed for single - # tool run and not extended usage. - memoize_session_reset() + # Reset all memoize session caches which are designed for single + # tool run and not extended usage. + memoize_session_reset() - # Reload checker to flush instance variables and thus any config - # or caches they may contain. - self.postoptparse() + # Reload checker to flush instance variables and thus any config + # or caches they may contain. + self.postoptparse() - continue - - break if __name__ == "__main__": app = CommandLineInterface()