commit:     ac9184e0b0445a9294ae47f71abe7117799a4577
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 05:11:53 2020 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jun 24 05:30:54 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ac9184e0

SpawnProcess._async_wait: allow _main_task to exit normally

Unnecessary cancellation of _main_task triggered this ResourceWarning
for the ebuild(1) fetch command, since it prevented cleanup of
BuildLogger's internal PipeLogger instance:

sys:1: ResourceWarning: unclosed file <_io.FileIO name=10 mode='rb' 
closefd=True>

Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/_emerge/SpawnProcess.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/_emerge/SpawnProcess.py b/lib/_emerge/SpawnProcess.py
index f96911571..60239a65a 100644
--- a/lib/_emerge/SpawnProcess.py
+++ b/lib/_emerge/SpawnProcess.py
@@ -172,12 +172,23 @@ class SpawnProcess(SubProcess):
                        raise
 
        def _main_exit(self, main_task):
+               self._main_task = None
                try:
                        main_task.result()
                except asyncio.CancelledError:
                        self.cancel()
                self._async_waitpid()
 
+       def _async_wait(self):
+               # Allow _main_task to exit normally rather than via 
cancellation.
+               if self._main_task is None:
+                       super(SpawnProcess, self)._async_wait()
+
+       def _async_waitpid(self):
+               # Allow _main_task to exit normally rather than via 
cancellation.
+               if self._main_task is None:
+                       super(SpawnProcess, self)._async_waitpid()
+
        def _can_log(self, slave_fd):
                return True
 

Reply via email to