def _daemon(callback, run_interval):
    global BUSY
    signal.signal(signal.SIGTERM, handle_term)
    signal.signal(signal.SIGHUP, handle_term)

    while True:
        BUSY = True
        callback()
        BUSY = False
        if KILLED:
            logging.info('exit loop')
            break

        if run_interval > 0:
            logging.info('will rerun after %s seconds',
                         flags.OPTIONS.run_interval)
            time.sleep(flags.OPTIONS.run_interval)
        else:
            logging.info('finish loop')
            break
help function to run callback in daemon.
dataset/ETHPy150Open openstack/compass-core/compass/utils/daemonize.py/_daemon