commit:     855c8761f85323bbe570ae61e87c57dc8ea5ea0e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Feb  8 09:08:07 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Feb  8 09:10:49 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=855c8761

PopenProcess: suppress ResourceWarning subprocess "still running" (bug 608594)

Override the _set_returncode method to set the Popen.returncode
attribute, in order to suppress Python 3.6 ResourceWarnings which
erroneously report that the subprocess is still running.

X-Gentoo-Bug: 608594
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=608594

 pym/portage/util/_async/PopenProcess.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/pym/portage/util/_async/PopenProcess.py 
b/pym/portage/util/_async/PopenProcess.py
index 2fc56d295..4344b1c9d 100644
--- a/pym/portage/util/_async/PopenProcess.py
+++ b/pym/portage/util/_async/PopenProcess.py
@@ -1,4 +1,4 @@
-# Copyright 2012 Gentoo Foundation
+# Copyright 2012-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from _emerge.SubProcess import SubProcess
@@ -31,3 +31,10 @@ class PopenProcess(SubProcess):
                self._reg_id = None
                self._waitpid_cb(pid, condition)
                self.wait()
+
+       def _set_returncode(self, wait_retval):
+               SubProcess._set_returncode(self, wait_retval)
+               if self.proc.returncode is None:
+                       # Suppress warning messages like this:
+                       # ResourceWarning: subprocess 1234 is still running
+                       self.proc.returncode = self.returncode

Reply via email to