From 0df535d2f3115901a429930b90ff1fbc2b04df9e Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 16 Mar 2011 18:19:02 -0700 Subject: [PATCH] AsynchronousTask: always call wait() if cancelled This is needed in order to ensure that exit listeners are called. Subclasses call the base class cancel() method in order to inherit the wait() call. --- pym/_emerge/CompositeTask.py | 3 ++- pym/_emerge/FifoIpcDaemon.py | 4 ++-- pym/_emerge/PipeReader.py | 4 ++-- pym/_emerge/SubProcess.py | 6 +----- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pym/_emerge/CompositeTask.py b/pym/_emerge/CompositeTask.py index ddbfe6364..4667b7813 100644 --- a/pym/_emerge/CompositeTask.py +++ b/pym/_emerge/CompositeTask.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.AsynchronousTask import AsynchronousTask @@ -15,6 +15,7 @@ class CompositeTask(AsynchronousTask): self.cancelled = True if self._current_task is not None: self._current_task.cancel() + AsynchronousTask.cancel(self) def _poll(self): """ diff --git a/pym/_emerge/FifoIpcDaemon.py b/pym/_emerge/FifoIpcDaemon.py index ac83646b9..c31508a83 100644 --- a/pym/_emerge/FifoIpcDaemon.py +++ b/pym/_emerge/FifoIpcDaemon.py @@ -1,4 +1,4 @@ -# Copyright 2010 Gentoo Foundation +# Copyright 2010-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from portage import os @@ -48,7 +48,7 @@ class FifoIpcDaemon(AbstractPollTask): self.returncode = 1 self.cancelled = True self._unregister() - self.wait() + AbstractPollTask.cancel(self) def _wait(self): if self.returncode is not None: diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py index 6952ffd7e..061921a79 100644 --- a/pym/_emerge/PipeReader.py +++ b/pym/_emerge/PipeReader.py @@ -1,4 +1,4 @@ -# Copyright 1999-2010 Gentoo Foundation +# Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from portage import os @@ -36,7 +36,7 @@ class PipeReader(AbstractPollTask): if self.returncode is None: self.returncode = 1 self.cancelled = True - self.wait() + AbstractPollTask.cancel(self) def _wait(self): if self.returncode is not None: diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py index fc035d1e4..16c71fe3b 100644 --- a/pym/_emerge/SubProcess.py +++ b/pym/_emerge/SubProcess.py @@ -49,11 +49,7 @@ class SubProcess(AbstractPollTask): if e.errno != errno.ESRCH: raise del e - - self.cancelled = True - if self.pid is not None: - self.wait() - return self.returncode + AbstractPollTask.cancel(self) def isAlive(self): return self.pid is not None and \ -- 2.26.2