From 5005d912e1585cd34b08f1f6faefb17e3c9d4c4d Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 8 Oct 2010 20:46:13 +0200 Subject: unrar renice --- module/pyunrar.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'module/pyunrar.py') diff --git a/module/pyunrar.py b/module/pyunrar.py index 8b9892f8e..14379ffcb 100644 --- a/module/pyunrar.py +++ b/module/pyunrar.py @@ -90,10 +90,7 @@ class Unrar(): if os.name == "nt": self.cmd = [join(pypath, "UnRAR.exe")] else: - if cpu: - self.cmd = ["nice", "-%s" % cpu,"unrar"] - else: - self.cmd = ["unrar"] + self.cmd = ["unrar"] self.encrypted = None self.headerEncrypted = None self.smallestFiles = None @@ -104,7 +101,16 @@ class Unrar(): self.tmpdir = tmpdir +"_" + basename(archive).replace(".rar", "").replace(".","") self.ram = ramSize + self.cpu = cpu + + def renice(self, p): + """ renice process """ + if os.name != "nt" and self.cpu: + try: + Popen(["renice", self.cpu, p.pid], stdout=PIPE, bufsize=-1) + except: + print "Renice failed" def listContent(self, password=None): """ @@ -222,6 +228,7 @@ class Unrar(): except WrongPasswordError: return False p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=-1) + self.renice(p) (ret, out) = self.processOutput(p, statusFunction) if ret == 3: raise False @@ -259,6 +266,7 @@ class Unrar(): if destination: args.append(destination) p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=-1) + self.renice(p) (ret, out) = self.processOutput(p, statusFunction) if ret == 3: raise WrongPasswordError() -- cgit v1.2.3