[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).
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user