From e43023bf16f502ca0e8f978804423fc4be86d06b Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Fri, 28 Jun 2019 13:40:06 -0700 Subject: [PATCH] transcode checker: longer retry while waiting for videos to finish but still check db often. This prevents us from using too much api quota on these checks, while still letting us spot new videos quickly. --- cutter/cutter/main.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cutter/cutter/main.py b/cutter/cutter/main.py index 37a2d49..60e8735 100644 --- a/cutter/cutter/main.py +++ b/cutter/cutter/main.py @@ -400,8 +400,9 @@ class Cutter(object): class TranscodeChecker(object): - NO_VIDEOS_RETRY_INTERVAL = 5 - ERROR_RETRY_INTERVAL = 5 + NO_VIDEOS_RETRY_INTERVAL = 5 # can be fast because it's just a DB lookup + FOUND_VIDEOS_RETRY_INTERVAL = 20 + ERROR_RETRY_INTERVAL = 20 def __init__(self, youtube, dbmanager, stop): """ @@ -428,12 +429,11 @@ class TranscodeChecker(object): continue self.logger.info("Found {} videos in TRANSCODING".format(len(ids))) ids = self.check_ids(ids) - if not ids: - self.wait(self.NO_VIDEOS_RETRY_INTERVAL) - continue - self.logger.info("{} videos are done".format(len(ids))) - done = self.mark_done(ids) - self.logger.info("Marked {} videos as done".format(done)) + if ids: + self.logger.info("{} videos are done".format(len(ids))) + done = self.mark_done(ids) + self.logger.info("Marked {} videos as done".format(done)) + self.wait(self.FOUND_VIDEOS_RETRY_INTERVAL) except Exception: self.logger.exception("Error in TranscodeChecker") # To ensure a fresh slate and clear any DB-related errors, get a new conn on error.