commit:     391daef6fce981acd5a01e41a0f7238044c48877
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 26 08:29:04 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Apr 26 08:43:53 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=391daef6

MirrorDistTask._term_callback(): use _async_wait() (bug 591760)

Use _async_wait() to avoid event loop recursion, but don't call
it prematurely, since since that could trigger event loop recursion
if the current (cancelled) task's exit callback does not set the
returncode first.

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

 pym/portage/_emirrordist/MirrorDistTask.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/pym/portage/_emirrordist/MirrorDistTask.py 
b/pym/portage/_emirrordist/MirrorDistTask.py
index a34f2c061..48d0f7cf2 100644
--- a/pym/portage/_emirrordist/MirrorDistTask.py
+++ b/pym/portage/_emirrordist/MirrorDistTask.py
@@ -231,7 +231,15 @@ class MirrorDistTask(CompositeTask):
                if self._fetch_iterator is not None:
                        self._fetch_iterator.terminate()
                self.cancel()
-               self.wait()
+               if self.returncode is None:
+                       # In this case, the exit callback for 
self._current_task will
+                       # trigger notification of exit listeners. Don't call 
_async_wait()
+                       # yet, since that could trigger event loop recursion if 
the
+                       # current (cancelled) task's exit callback does not set 
the
+                       # returncode first.
+                       pass
+               else:
+                       self._async_wait()
 
        def _wait(self):
                CompositeTask._wait(self)

Reply via email to