diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-03-16 22:36:33 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-03-16 22:36:33 -0700 |
commit | 363a7478a100495d2e8597bc6c6d2fdac94339e0 (patch) | |
tree | 263a2e0a87442ca59634471de0ad0f3bb369ae8a /pym/_emerge/AsynchronousTask.py | |
parent | 5283edc81874fdf5ddf157c3f85032b63955ac86 (diff) | |
download | portage-363a7478a100495d2e8597bc6c6d2fdac94339e0.tar.gz portage-363a7478a100495d2e8597bc6c6d2fdac94339e0.tar.bz2 portage-363a7478a100495d2e8597bc6c6d2fdac94339e0.zip |
AsynchronousTask: add _cancel template method
Diffstat (limited to 'pym/_emerge/AsynchronousTask.py')
-rw-r--r-- | pym/_emerge/AsynchronousTask.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/pym/_emerge/AsynchronousTask.py b/pym/_emerge/AsynchronousTask.py index 1918b839b..de0080042 100644 --- a/pym/_emerge/AsynchronousTask.py +++ b/pym/_emerge/AsynchronousTask.py @@ -1,4 +1,4 @@ -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from _emerge.SlotObject import SlotObject @@ -45,8 +45,17 @@ class AsynchronousTask(SlotObject): return self.returncode def cancel(self): - self.cancelled = True - self.wait() + if not self.cancelled: + self.cancelled = True + self._cancel() + self.wait() + + def _cancel(self): + """ + Subclasses should implement this, as a template method + to be called by AsynchronousTask.cancel(). + """ + pass def addStartListener(self, f): """ |