Ubuntu Pastebin

Paste from stgraber at Thu, 26 Feb 2015 19:32:32 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--- /tmp/a	2015-02-26 19:25:53.726210362 +0000
+++ /usr/bin/unattended-upgrade	2015-02-26 19:32:22.815771380 +0000
@@ -938,7 +938,13 @@ def main(options, rootdir=""):
 
     # FIXME: make this into a ContextManager
     # be nice when calculating the upgrade as its pretty CPU intensive
-    os.nice(19)
+    old_priority = os.nice(0)
+    try:
+        # Check that we will be able to restore the priority
+        os.nice(-1)
+        os.nice(20)
+    except PermissionError:
+        pass
 
     # speed things up with latest apt
     actiongroup = apt_pkg.ActionGroup(cache._depcache)
@@ -990,7 +996,7 @@ def main(options, rootdir=""):
 
     # FIXME: make this into a ContextManager
     # stop being nice
-    os.nice(-19)
+    os.nice(old_priority - os.nice(0))
 
     # download what looks good
     if options.debug:
Download as text