From 24f447e45ebe752b41b56b930f1c5bf26dfe3433 Mon Sep 17 00:00:00 2001 From: lxnay Date: Mon, 5 May 2008 18:02:53 +0000 Subject: [PATCH] Entropy: - introduce preliminary priority management infrastructure git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@1918 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- libraries/entropy.py | 13 +++++++++++++ libraries/entropyConstants.py | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/libraries/entropy.py b/libraries/entropy.py index 06a9c7d6e..c5e28442b 100644 --- a/libraries/entropy.py +++ b/libraries/entropy.py @@ -280,6 +280,16 @@ class EquoInterface(TextInterface): else: raise exceptionTools.InvalidData("InvalidData: nothing to backup in etpConst with %s key" % (setting_name,)) + def set_priority(self, low = 0): + default_nice = etpConst['default_nice'] + current_nice = etpConst['current_nice'] + delta = current_nice - default_nice + try: + etpConst['current_nice'] = os.nice(delta*-1+low) + except OSError: + pass + return current_nice # aka, the old value + def switchChroot(self, chroot = ""): # clean caches self.purge_cache() @@ -5895,6 +5905,8 @@ class RepoInterface: ) if self.Entropy.indexing: + # renice a bit, to avoid eating resources + old_prio = self.Entropy.set_priority(15) self.Entropy.updateProgress( red("Indexing Repository metadata ..."), importance = 1, @@ -5913,6 +5925,7 @@ class RepoInterface: self.Entropy.clientDbconn.createAllIndexes() except: pass + self.Entropy.set_priority(old_prio) # update revision in etpRepositories self.Entropy.update_repository_revision(repo) diff --git a/libraries/entropyConstants.py b/libraries/entropyConstants.py index 50a135404..de4417c0e 100644 --- a/libraries/entropyConstants.py +++ b/libraries/entropyConstants.py @@ -651,6 +651,9 @@ def const_defaultSettings(rootdir): 'sysgroup': "entropy", 'defaultumask': 022, 'storeumask': 002, + 'gentle_nice': 15, + 'current_nice': 0, + 'default_nice': 0, 'server_treeupdatescalled': set(), 'client_treeupdatescalled': set(), 'spm': { @@ -763,6 +766,13 @@ def const_defaultSettings(rootdir): }, } + + # set current nice level + try: + myConst['current_nice'] = os.nice(0) + except OSError: + pass + etpConst.update(myConst)