AsynchronousTask: always call wait() if cancelled
authorZac Medico <zmedico@gentoo.org>
Thu, 17 Mar 2011 01:19:02 +0000 (18:19 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 18 Mar 2011 19:47:22 +0000 (12:47 -0700)
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
pym/_emerge/FifoIpcDaemon.py
pym/_emerge/PipeReader.py
pym/_emerge/SubProcess.py

index ddbfe6364e8db76ea4c4429950b871539124485d..4667b781343159b207ff62fb59305ee42dd6040d 100644 (file)
@@ -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):
                """
index ac83646b9f17dd572a6a09c1055c989ffef297dd..c31508a839cbec66e80024d46752516ac0cd09ac 100644 (file)
@@ -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:
index 6952ffd7e6a68bd1bba5ac3672da0290d0aff633..061921a791ec6947d45e87ebcfbdf03882dd5e35 100644 (file)
@@ -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:
index fc035d1e4276c97aae9196028a963cb6508d6131..16c71fe3b45f2b19bd51bf6b4cf8de7adef95914 100644 (file)
@@ -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 \