Exit after killed while waiting on prefetch.
authorZac Medico <zmedico@gentoo.org>
Fri, 9 Mar 2012 05:08:40 +0000 (21:08 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 9 Mar 2012 05:08:40 +0000 (21:08 -0800)
pym/_emerge/AsynchronousTask.py
pym/_emerge/Binpkg.py
pym/_emerge/EbuildBuild.py

index df72bae556b0c931ab9d3c0c0ac1b9099ca4bb87..7a193ce7dd8facd4fdf7286b62fc08e660bf4c0a 100644 (file)
@@ -1,6 +1,8 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+import signal
+
 from portage import os
 from portage.util.SlotObject import SlotObject
 
@@ -18,6 +20,8 @@ class AsynchronousTask(SlotObject):
                ("_exit_listeners", "_exit_listener_stack", "_start_listeners",
                "_waiting")
 
+       _cancelled_returncode = - signal.SIGINT
+
        def start(self):
                """
                Start an asynchronous task and then return as soon as possible.
@@ -76,6 +80,17 @@ class AsynchronousTask(SlotObject):
                """
                pass
 
+       def _was_cancelled(self):
+               """
+               If cancelled, set returncode if necessary and return True.
+               Otherwise, return False.
+               """
+               if self.cancelled:
+                       if self.returncode is None:
+                               self.returncode = self._cancelled_returncode
+                       return True
+               return False
+
        def addStartListener(self, f):
                """
                The function will be called with one argument, a reference to self.
index 395a506c3ee295af2411b3acfda645cb6fc68df0..ea8a1ad13a0da2fb98f43e4b1e1635a9d38c615e 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from _emerge.EbuildPhase import EbuildPhase
@@ -104,6 +104,10 @@ class Binpkg(CompositeTask):
 
        def _prefetch_exit(self, prefetcher):
 
+               if self._was_cancelled():
+                       self.wait()
+                       return
+
                pkg = self.pkg
                pkg_count = self.pkg_count
                if not (self.opts.pretend or self.opts.fetchonly):
index 6e37cdaaa8e13fb03ad87b578e2e8783a4e01a55..27aa7ca05b05e7c542bd54c8d5d640eaa59e0ad6 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from _emerge.EbuildExecuter import EbuildExecuter
@@ -107,6 +107,10 @@ class EbuildBuild(CompositeTask):
 
        def _prefetch_exit(self, prefetcher):
 
+               if self._was_cancelled():
+                       self.wait()
+                       return
+
                opts = self.opts
                pkg = self.pkg
                settings = self.settings