summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/AsynchronousTask.py
diff options
context:
space:
mode:
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.