From 66ea6917d966b43f6a7714d4dd8a2b87e0d57ddc Mon Sep 17 00:00:00 2001 From: Filipe Santos Date: Sun, 22 Apr 2018 16:53:37 +1200 Subject: [PATCH] Add docker build by branch --- traktarr.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/traktarr.py b/traktarr.py index 97c7f14..5e14706 100755 --- a/traktarr.py +++ b/traktarr.py @@ -493,21 +493,32 @@ def automatic_movies(add_delay=2.5, no_search=False, notifications=False): def run(add_delay=2.5, no_search=False, no_notifications=False): # add tasks to repeat if cfg.automatic.movies.interval: - schedule.every(cfg.automatic.movies.interval).hours.do(automatic_movies, add_delay, no_search, - not no_notifications) + schedule.every(cfg.automatic.movies.interval).hours.do( + automatic_movies, + add_delay, + no_search, + not no_notifications + ) + if cfg.automatic.shows.interval: - schedule.every(cfg.automatic.shows.interval).hours.do(automatic_shows, add_delay, no_search, - not no_notifications) + schedule.every(cfg.automatic.shows.interval).hours.do( + automatic_shows, + add_delay, + no_search, + not no_notifications + ) # run schedule log.info("Automatic mode is now running...") while True: try: + # Sleep until next run + time.sleep(schedule.idle_seconds()) + # Check jobs to run schedule.run_pending() - except Exception: - log.exception("Unhandled exception occurred while processing scheduled tasks: ") - else: - time.sleep(1) + + except Exception as e: + log.exception("Unhandled exception occurred while processing scheduled tasks: %s", e) ############################################################