diff options
author | Zac Medico <zmedico@gentoo.org> | 2021-06-17 10:43:49 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2021-06-17 10:45:00 -0700 |
commit | 03520f0ac680d6af62176beb4a072750c11c0b49 (patch) | |
tree | 8333a748a87ff5a03b507d4b9450045a99b6737e /lib/_emerge/actions.py | |
parent | setup.cfg: eliminate dash-separated portage-ext-modules (diff) | |
download | portage-03520f0ac680d6af62176beb4a072750c11c0b49.tar.gz portage-03520f0ac680d6af62176beb4a072750c11c0b49.tar.bz2 portage-03520f0ac680d6af62176beb4a072750c11c0b49.zip |
Revert "PORTAGE_NICENESS: Consider autogroup scheduling"
This reverts commit 055abe523c2c3f6c8f1dccfb53565209222f90c1
due to another regression.
See: https://github.com/gentoo/portage/pull/728
Bug: https://bugs.gentoo.org/777492
Bug: https://bugs.gentoo.org/785484
Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/_emerge/actions.py')
-rw-r--r-- | lib/_emerge/actions.py | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/lib/_emerge/actions.py b/lib/_emerge/actions.py index df5c86c6c..1946f49df 100644 --- a/lib/_emerge/actions.py +++ b/lib/_emerge/actions.py @@ -14,7 +14,6 @@ import textwrap import time import warnings from itertools import chain -from pathlib import Path import portage portage.proxy.lazyimport.lazyimport(globals(), @@ -2635,55 +2634,14 @@ def apply_priorities(settings): nice(settings) def nice(settings): - nice_value: str = settings.get("PORTAGE_NICENESS", "").strip() - if not nice_value: - return - try: - current_nice_value = os.nice(int(nice_value)) - # Calling os.nice() with a value outside of the valid range of - # nice values, e.g. 20, caps the process's nice value. This is - # because the argument of os.nice() is not an absolute value, - # but the increment to the process's current nice - # value. Hence users may use PORTAGE_NICENESS=20 without any - # issues here. However, below we write nice_value potentially - # to /proc/self/autogroup, which will only accept valid nice - # values. Therefore we simply set nice_value to what os.nice() - # returned (i.e. the process's current nice value). - nice_value = str(current_nice_value) + os.nice(int(settings.get("PORTAGE_NICENESS", "0"))) except (OSError, ValueError) as e: out = portage.output.EOutput() - out.eerror(f"Failed to change nice value to {nice_value}") + out.eerror("Failed to change nice value to '%s'" % \ + settings.get("PORTAGE_NICENESS", "0")) out.eerror("%s\n" % str(e)) - autogroup_file = Path("/proc/self/autogroup") - try: - f = autogroup_file.open("r+") - except EnvironmentError: - # Autogroup scheduling is not enabled on this system. - return - - with f: - line = f.readline() - original_autogroup_nice_value = line.split(" ")[2] - - # We need to restore the original nice value of the - # autogroup, as otherwise the session, e.g. the - # terminal where portage was executed in, would - # continue running with that value. - portage.atexit_register( - lambda value: autogroup_file.write_text(value), - original_autogroup_nice_value, - ) - - try: - f.write(nice_value) - except EnvironmentError as e: - out = portage.output.EOutput() - out.eerror(f"Failed to change autogroup's nice value to {nice_value}") - out.eerror("%s\n" % str(e)) - - def ionice(settings): ionice_cmd = settings.get("PORTAGE_IONICE_COMMAND") |