Skip to content

Commit 82e8a9b

Browse files
authored
Mentor Requests: add randomness to the Exercism track polling interval (#150)
1 parent 77e2cfe commit 82e8a9b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cogs/mentor_requests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ def queue_query_exercism(self, track: str) -> None:
231231
"""Queue a task to query Exercism for a track."""
232232
interval = self.exercism_poll_interval(track)
233233
PROM_EXERCISM_INTERVAL.labels(track).set(interval)
234+
# Fuzz the delay. Wait at least the min. Wait 50-100% of the additional time.
235+
half_over = (interval - EXERCISM_TRACK_POLL_MIN_SECONDS) // 2
236+
interval = EXERCISM_TRACK_POLL_MIN_SECONDS + half_over + random.randint(0, half_over)
237+
234238
task_time = int(time.time()) + interval
235239
logger.debug("Queue TASK_QUERY_EXERCISM %s in %d seconds", track, interval)
236240
self.queue.put_nowait((task_time, TaskType.TASK_QUERY_EXERCISM, track, None))

0 commit comments

Comments
 (0)