From 34e8d0a64b34ff47370cab0da1ef33cb7a4b9b54 Mon Sep 17 00:00:00 2001 From: Christopher Usher Date: Wed, 30 Oct 2019 01:36:31 +0000 Subject: [PATCH] Handle the case where an hour directory disappears between listing the hours and trying to list the segments in that hour. This could happen if the backfiller is deleting old hours. --- segment_coverage/segment_coverage/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/segment_coverage/segment_coverage/main.py b/segment_coverage/segment_coverage/main.py index 345b979..b3fa57a 100644 --- a/segment_coverage/segment_coverage/main.py +++ b/segment_coverage/segment_coverage/main.py @@ -192,7 +192,7 @@ class CoverageChecker(object): hours = [name for name in os.listdir(path) if not name.startswith('.')] except OSError as e: if e.errno == errno.ENOENT: - self.logger.warning('{} does not exist') + self.logger.warning('{} does not exist'.format(path)) break hours.sort() @@ -207,7 +207,12 @@ class CoverageChecker(object): # based on common.segments.best_segments_by_start # but more complicated to capture more detailed metrics hour_path = os.path.join(self.base_dir, self.channel, quality, hour) - segment_names = [name for name in os.listdir(hour_path) if not name.startswith('.')] + try: + segment_names = [name for name in os.listdir(hour_path) if not name.startswith('.')] + except OSError as e: + if e.errno == errno.ENOENT: + self.logger.warning('{} does not exist'.format(hour_path)) + break segment_names.sort() parsed = [] bad_segment_count = 0