# 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
("_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.
"""
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.
-# 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
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):
-# 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
def _prefetch_exit(self, prefetcher):
+ if self._was_cancelled():
+ self.wait()
+ return
+
opts = self.opts
pkg = self.pkg
settings = self.settings