From fa0eb83df4eb79d0bb69e3141a3ae7e5c5c55b5b Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 2 Sep 2012 17:00:03 +0200 Subject: [PATCH] [RigoDaemon] half the timer frequency and add some randomization in _auto_repositories_update() When sabayon-weekly is updated, the web service is hit by a huge amount of requests. This commits add a bit more entropy on the execution of _auto_repositories_update() (random between 30mins to 2 hours) and reduces the timer frequency to 8hrs (from 4). --- rigo/RigoDaemon/app.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rigo/RigoDaemon/app.py b/rigo/RigoDaemon/app.py index 617b8d1ed..1cebf2d7e 100755 --- a/rigo/RigoDaemon/app.py +++ b/rigo/RigoDaemon/app.py @@ -12,6 +12,8 @@ """ import os import stat +import random +random.seed() # entropy.i18n will pick this up os.environ['ETP_GETTEXT_DOMAIN'] = "rigo" @@ -750,7 +752,7 @@ class RigoDaemonService(dbus.service.Object): Start timer thread that handles automatic repositories update. """ - task = Timer(3600 * 4, self._auto_repositories_update) + task = Timer(3600 * 8, self._auto_repositories_update) task.daemon = True task.name = "AutoRepositoriesUpdateTimer" task.start() @@ -861,6 +863,11 @@ class RigoDaemonService(dbus.service.Object): """ Execute automatic Repositories Update Activity. """ + # Add entropy to the scheduled execution to + # avoid bursts against the web service + rand_secs = random.randint(1800, 7200) + time.sleep(rand_secs) + if self._is_system_on_batteries(): self._start_repositories_update_timer() return