def enqueue(action: Callable): new_delay = datetime.now() # new_delay = datetime.now().replace(second=0, microsecond=0) new_delay += timedelta(seconds=settings.DELAY) logger.info(f"Next call will be made at {new_delay}") cron.enterabs(new_delay.timestamp(), priority=settings.PRIORITY, action=action)
import time import schedule from dynaconf import settings from fexservice.consumer import fetch_github from fexservice.logger import logger logger.info(f"The DELAY was set to {settings.DELAY} seconds" + f"and PRIORITY to {settings.PRIORITY}") def job(): fetch_github() schedule.every(settings.DELAY).seconds.do(job) while True: schedule.run_pending() time.sleep(1)