Replace exit listener usage with a TaskSequence instance,
in order to guarantee that _record_binpkg_info executes
immediately after EbuildBinpkg. This approach is similar to
that used to fix bug 562264.

X-Gentoo-bug: 578204
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=578204
---
 pym/_emerge/EbuildBuild.py | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py
index 95c14e4..2941511 100644
--- a/pym/_emerge/EbuildBuild.py
+++ b/pym/_emerge/EbuildBuild.py
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
 import io
 
 import _emerge.emergelog
+from _emerge.AsynchronousTask import AsynchronousTask
 from _emerge.EbuildExecuter import EbuildExecuter
 from _emerge.EbuildPhase import EbuildPhase
 from _emerge.EbuildBinpkg import EbuildBinpkg
@@ -320,13 +321,18 @@ class EbuildBuild(CompositeTask):
                                                phase="rpm", 
scheduler=self.scheduler,
                                                settings=self.settings))
                                else:
+                                       # Use task_seq to guarantee that 
_RecordBinpkgInfo
+                                       # is called immediately after 
EbuildBinpkg, in order
+                                       # to solve bug #578204.
+                                       task_seq = TaskSequence()
                                        task = EbuildBinpkg(
                                                background=self.background,
                                                pkg=self.pkg, 
scheduler=self.scheduler,
                                                settings=self.settings)
-                                       binpkg_tasks.add(task)
-                                       task.addExitListener(
-                                               self._record_binpkg_info)
+                                       task_seq.add(task)
+                                       task_seq.add(self._RecordBinpkgInfo(
+                                               ebuild_binpkg=task, 
ebuild_build=self))
+                                       binpkg_tasks.add(task_seq)
 
                if binpkg_tasks:
                        self._start_task(binpkg_tasks, self._buildpkg_exit)
@@ -335,6 +341,14 @@ class EbuildBuild(CompositeTask):
                self._final_exit(build)
                self.wait()
 
+       class _RecordBinpkgInfo(AsynchronousTask):
+
+               __slots__ = ('ebuild_binpkg', 'ebuild_build',)
+
+               def _start(self):
+                       
self.ebuild_build._record_binpkg_info(self.ebuild_binpkg)
+                       AsynchronousTask._start(self)
+
        def _buildpkg_exit(self, packager):
                """
                Released build dir lock when there is a failure or
-- 
2.7.2


Reply via email to