ReviewBot: Simplify the !interval case
We only want to run the workfunc() and that's it
This commit is contained in:
parent
ad7abc06aa
commit
606e498554
50
ReviewBot.py
50
ReviewBot.py
@ -845,10 +845,12 @@ class CommandLineInterface(cmdln.Cmdln):
|
|||||||
class ExTimeout(Exception):
|
class ExTimeout(Exception):
|
||||||
"""raised on timeout"""
|
"""raised on timeout"""
|
||||||
|
|
||||||
if interval:
|
if not interval:
|
||||||
def alarm_called(nr, frame):
|
return workfunc()
|
||||||
raise ExTimeout()
|
|
||||||
signal.signal(signal.SIGALRM, alarm_called)
|
def alarm_called(nr, frame):
|
||||||
|
raise ExTimeout()
|
||||||
|
signal.signal(signal.SIGALRM, alarm_called)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -856,31 +858,27 @@ class CommandLineInterface(cmdln.Cmdln):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.exception(e)
|
self.logger.exception(e)
|
||||||
|
|
||||||
if interval:
|
if os.isatty(0):
|
||||||
if os.isatty(0):
|
self.logger.info("sleeping %d minutes. Press enter to check now ..."%interval)
|
||||||
self.logger.info("sleeping %d minutes. Press enter to check now ..."%interval)
|
signal.alarm(interval*60)
|
||||||
signal.alarm(interval*60)
|
try:
|
||||||
try:
|
input()
|
||||||
input()
|
except ExTimeout:
|
||||||
except ExTimeout:
|
pass
|
||||||
pass
|
signal.alarm(0)
|
||||||
signal.alarm(0)
|
self.logger.info("recheck at %s"%datetime.datetime.now().isoformat())
|
||||||
self.logger.info("recheck at %s"%datetime.datetime.now().isoformat())
|
else:
|
||||||
else:
|
self.logger.info("sleeping %d minutes." % interval)
|
||||||
self.logger.info("sleeping %d minutes." % interval)
|
time.sleep(interval * 60)
|
||||||
time.sleep(interval * 60)
|
|
||||||
|
|
||||||
# Reset all memoize session caches which are designed for single
|
# Reset all memoize session caches which are designed for single
|
||||||
# tool run and not extended usage.
|
# tool run and not extended usage.
|
||||||
memoize_session_reset()
|
memoize_session_reset()
|
||||||
|
|
||||||
# Reload checker to flush instance variables and thus any config
|
# Reload checker to flush instance variables and thus any config
|
||||||
# or caches they may contain.
|
# or caches they may contain.
|
||||||
self.postoptparse()
|
self.postoptparse()
|
||||||
|
|
||||||
continue
|
|
||||||
|
|
||||||
break
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = CommandLineInterface()
|
app = CommandLineInterface()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user