Commit d5dd5a61 authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

allow ionice level to be setted

parent 11259acd
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -429,8 +429,10 @@ def arg_parser_init():
                        help="dot not display colored output")
    parser.add_argument("--nice", type=int, default=0,
                        help="nice of the process")
    parser.add_argument("--ionice", choices=["none","rt", "be","idle"],
    parser.add_argument("--ionice-class", choices=["none","rt", "be","idle"],
                        help="ionice class of the process (default: none)")
    parser.add_argument("--ionice-level", type=int, default=None,
                        help="ionice class level of the process")
    # create a subparser for commands
    subparser = parser.add_subparsers()
    # add command parser
@@ -667,22 +669,22 @@ def main():
        if installsystems.verbosity < 2:
            warnings.filterwarnings("ignore")
        # nice and ionice process
        if options.nice is not None or options.ionice is not None:
        if options.nice is not None or options.ionice_class is not None:
            proc = psutil.Process(os.getpid())
            if options.nice is not None:
                try: proc.nice = options.nice
                except Exception:
                    warn("Unable to nice process to %s" % options.nice)
            if options.ionice is not None:
            if options.ionice_class is not None:
                try:
                    ioclassmap = {
                        "none": psutil.IOPRIO_CLASS_NONE,
                        "rt": psutil.IOPRIO_CLASS_RT,
                        "be": psutil.IOPRIO_CLASS_BE,
                        "idle": psutil.IOPRIO_CLASS_IDLE}
                    proc.set_ionice(ioclassmap[options.ionice])
                    proc.set_ionice(ioclassmap[options.ionice_class], options.ionice_level)
                except Exception:
                    warn("Unable to ionice process to %s" % options.ionice)
                    warn("Unable to ionice process to %s" % options.ionice_class)
        # except for install command we parse all args!
        # install command is responsible of parsing
        if options.func is not c_install:
+2 −1
Original line number Diff line number Diff line
@@ -62,7 +62,8 @@ class MainConfigFile(ConfigFile):
        "repo_filter": str,
        "repo_config": str,
        "nice": int,
        "ionice": ["none", "rt", "be", "idle"]
        "ionice_class": ["none", "rt", "be", "idle"],
        "ionice_level": int
        }
    def __init__(self, filename, prefix=os.path.basename(sys.argv[0])):
        self.prefix = prefix
+6 −3
Original line number Diff line number Diff line
@@ -5,11 +5,14 @@
# Set verbosity (0: quiet, 1: normal, 2: debug)
#verbosity = 2

# Set nice process value
# Set nice process value (see nice (1))
#nice = 0

# Set ionice class
#ionice = idle
# Set ionice class (see ionice (1))
#ionice_class = idle

# Set ionice class data level (see ionice (1))
#ionice_level = 0

# define a custom cache directory
#cache = /tmp/sex