commit:     542c6e6c20a1d93a3a2af47c8de50eac3c891d5d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 29 20:48:23 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Apr 29 21:26:37 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=542c6e6c

MergeProcess: fix deprecated _set_returncode (bug 654276)

Move cleanup code from _set_returncode to _async_waitpid_cb,
since _set_returncode expects an os.waitpid return value which
is inconveniently different from the returncode that is passed to
asyncio.AbstractChildWatcher.add_child_handler callbacks.

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

 pym/portage/dbapi/_MergeProcess.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pym/portage/dbapi/_MergeProcess.py 
b/pym/portage/dbapi/_MergeProcess.py
index 35591af16..bfbe387e4 100644
--- a/pym/portage/dbapi/_MergeProcess.py
+++ b/pym/portage/dbapi/_MergeProcess.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2013 Gentoo Foundation
+# Copyright 2010-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import io
@@ -251,8 +251,12 @@ class MergeProcess(ForkProcess):
                                # in order to avoid a race condition.
                                os._exit(1)
 
-       def _set_returncode(self, wait_retval):
-               ForkProcess._set_returncode(self, wait_retval)
+       def _async_waitpid_cb(self, *args, **kwargs):
+               """
+               Override _async_waitpid_cb to perform cleanup that is
+               not necessarily idempotent.
+               """
+               ForkProcess._async_waitpid_cb(self, *args, **kwargs)
                if self.returncode == portage.const.RETURNCODE_POSTINST_FAILURE:
                        self.postinst_failure = True
                        self.returncode = os.EX_OK

Reply via email to