From b30345af97183cc3fae426258b3c19f50425cfba Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Fri, 31 Oct 2025 12:55:35 -0700 Subject: [PATCH] Mentor Requests: add randomness to the Exercism track polling interval --- cogs/mentor_requests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cogs/mentor_requests.py b/cogs/mentor_requests.py index 6d023f3..4cba025 100644 --- a/cogs/mentor_requests.py +++ b/cogs/mentor_requests.py @@ -231,6 +231,10 @@ def queue_query_exercism(self, track: str) -> None: """Queue a task to query Exercism for a track.""" interval = self.exercism_poll_interval(track) PROM_EXERCISM_INTERVAL.labels(track).set(interval) + # Fuzz the delay. Wait at least the min. Wait 50-100% of the additional time. + half_over = (interval - EXERCISM_TRACK_POLL_MIN_SECONDS) // 2 + interval = EXERCISM_TRACK_POLL_MIN_SECONDS + half_over + random.randint(0, half_over) + task_time = int(time.time()) + interval logger.debug("Queue TASK_QUERY_EXERCISM %s in %d seconds", track, interval) self.queue.put_nowait((task_time, TaskType.TASK_QUERY_EXERCISM, track, None))