commit:     3031af210e44af825096a7601fa368851428e661
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 21 20:13:53 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Apr 21 20:16:39 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3031af21

CompositeTask._wait: recurse less (bug 591760)

In order to reduce the amount of recursion, use a future to
wait for task exit.

Bug: https://bugs.gentoo.org/591760

 pym/_emerge/CompositeTask.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pym/_emerge/CompositeTask.py b/pym/_emerge/CompositeTask.py
index 40cf8596b..f3acc9696 100644
--- a/pym/_emerge/CompositeTask.py
+++ b/pym/_emerge/CompositeTask.py
@@ -82,7 +82,12 @@ class CompositeTask(AsynchronousTask):
                                # a different task or None. Something is wrong.
                                raise AssertionError("self._current_task has 
not " + \
                                        "changed since calling wait", self, 
task)
-                       task.wait()
+
+                       # This triggers less recursion than calling task.wait().
+                       waiter = self.scheduler.create_future()
+                       task.addExitListener(waiter.set_result)
+                       while not waiter.done():
+                               self.scheduler.iteration()
                        prev = task
 
                return self.returncode

Reply via email to