summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/AsynchronousTask.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-03-08 21:08:40 -0800
committerZac Medico <zmedico@gentoo.org>2012-03-08 21:08:40 -0800
commitbadeb48eae2a1d429902f654c2de60d67283ded7 (patch)
tree1886378b7b3debaf839078b234fa24000a7a1df9 /pym/_emerge/AsynchronousTask.py
parentf1475a5cb14539fc412d8fca393b7473399d9a5b (diff)
downloadportage-badeb48eae2a1d429902f654c2de60d67283ded7.tar.gz
portage-badeb48eae2a1d429902f654c2de60d67283ded7.tar.bz2
portage-badeb48eae2a1d429902f654c2de60d67283ded7.zip
Exit after killed while waiting on prefetch.
Diffstat (limited to 'pym/_emerge/AsynchronousTask.py')
-rw-r--r--pym/_emerge/AsynchronousTask.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/pym/_emerge/AsynchronousTask.py b/pym/_emerge/AsynchronousTask.py
index df72bae55..7a193ce7d 100644
--- a/pym/_emerge/AsynchronousTask.py
+++ b/pym/_emerge/AsynchronousTask.py
@@ -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.