From 39ee57ea5760c13d9e892c6a057ee7913f818d34 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 24 Jul 2008 14:43:37 +0000 Subject: Bug #206773 - Add a new PORTAGE_IONICE_COMMAND variable that emerge uses to adjust ionice priority, similar to PORTAGE_NICENESS but used more like FETCHCOMMAND since so that portage doesn't have to know anything about ionice options. The command should include a \${PID} place-holder to be substituted with an integer pid. svn path=/main/trunk/; revision=11182 --- pym/_emerge/__init__.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'pym/_emerge/__init__.py') diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 50462940d..6c25bafd3 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -12846,6 +12846,29 @@ def adjust_config(myopts, settings): settings["NOCOLOR"] = "true" settings.backup_changes("NOCOLOR") +def ionice(settings): + + ionice_cmd = settings.get("PORTAGE_IONICE_COMMAND") + if ionice_cmd: + ionice_cmd = shlex.split(ionice_cmd) + if not ionice_cmd: + return + + from portage.util import varexpand + variables = {"PID" : str(os.getpid())} + cmd = [varexpand(x, mydict=variables) for x in ionice_cmd] + + try: + rval = portage.process.spawn(cmd, env=os.environ) + except portage.exception.CommandNotFound: + # The OS kernel probably doesn't support ionice, + # so return silently. + return + + if rval != os.EX_OK: + out = portage.output.EOutput() + out.eerror("PORTAGE_IONICE_COMMAND returned %d" % (rval,)) + def emerge_main(): global portage # NFC why this is necessary now - genone portage._disable_legacy_globals() @@ -12867,6 +12890,8 @@ def emerge_main(): settings, trees, mtimedb = load_emerge_config() portdb = trees[settings["ROOT"]]["porttree"].dbapi + ionice(settings) + try: os.nice(int(settings.get("PORTAGE_NICENESS", "0"))) except (OSError, ValueError), e: -- cgit v1.2.3-1-g7c22