From 2efdda45d06b57d8d69c11b3feef9b7c673a311b Mon Sep 17 00:00:00 2001 From: DevilXD Date: Tue, 19 Apr 2022 18:02:05 +0200 Subject: [PATCH] Fix mnt task min usage with an empty iterable --- twitch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/twitch.py b/twitch.py index cf90497..78103e8 100644 --- a/twitch.py +++ b/twitch.py @@ -466,10 +466,12 @@ class Twitch: # 1h at max, but can be shorter if there's an upcoming campaign earlier than that # divide the period into up to two evenly spaced checks (usually ~15-30m) now = datetime.now(timezone.utc) + one_hour = timedelta(hours=1) period = min( - campaign.starts_at - now for campaign in self.inventory if campaign.starts_at > now + (campaign.starts_at - now for campaign in self.inventory if campaign.starts_at > now), + default=one_hour, ) - if period > (one_hour := timedelta(hours=1)): + if period > one_hour: period = one_hour times = ceil(period.total_seconds() / 30 * 60) period /= times