def forever(self, interval_seconds = 1, cb_interval_func = None, func_data = None): counter = 0 interval = interval_seconds * 10 while not self.is_stop(): time.sleep(0.1) counter += 1 if counter == interval: counter = 0 if cb_interval_func: try: cb_interval_func(func_data) except: util.except_print("cb_interval_func") pass pass # block wait child processes exit for pname in self.workers.keys(): self.workers[pname].join() util.warn("{}: worker stopped.".format(pname)) with self.glock: util.remove_file_nothrow(self.pidfile) util.remove_file_nothrow(self.stopfile) pass
def check_forcestop(self, forcestop, exitCode = 0): if forcestop: self.notify_stop(exitCode) else: util.remove_file_nothrow(self.stopfile) pass