From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 58FE91382C5 for ; Sun, 22 Apr 2018 18:26:06 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 44FFFE0844; Sun, 22 Apr 2018 18:26:05 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 25480E0844 for ; Sun, 22 Apr 2018 18:26:05 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EAF91335C2C for ; Sun, 22 Apr 2018 18:26:03 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A6A5A27F for ; Sun, 22 Apr 2018 18:26:01 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1524421015.c5ab0696cec1f0f020d2d8ad416f9b1444a467de.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/SubProcess.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: c5ab0696cec1f0f020d2d8ad416f9b1444a467de X-VCS-Branch: master Date: Sun, 22 Apr 2018 18:26:01 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 08a49135-ef3f-4466-bf02-e59c82667945 X-Archives-Hash: 5d2572d7735a6e45a41819122ef8e162 commit: c5ab0696cec1f0f020d2d8ad416f9b1444a467de Author: Zac Medico gentoo org> AuthorDate: Sun Apr 22 18:16:55 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Apr 22 18:16:55 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c5ab0696 SubProcess: fix _unregister_if_appropriate event loop recursion (bug 614104) Override the AbstractPollTask._unregister_if_appropriate method to avoid event loop recursion when the pid exit status is not yet available, by calling self._async_waitpid() instead of self.wait(). Also make _async_waitpid fallback to _async_wait if the pid exit status happens to be available already. Bug: https://bugs.gentoo.org/614104 pym/_emerge/SubProcess.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py index 141181d9f..f684c5a22 100644 --- a/pym/_emerge/SubProcess.py +++ b/pym/_emerge/SubProcess.py @@ -108,7 +108,9 @@ class SubProcess(AbstractPollTask): prefered over _waitpid_loop, since the synchronous nature of _waitpid_loop can cause event loop recursion. """ - if self._waitpid_id is None: + if self.returncode is not None: + self._async_wait() + elif self._waitpid_id is None: self._waitpid_id = self.scheduler.child_watch_add( self.pid, self._async_waitpid_cb) @@ -158,6 +160,22 @@ class SubProcess(AbstractPollTask): f.close() self._files = None + def _unregister_if_appropriate(self, event): + """ + Override the AbstractPollTask._unregister_if_appropriate method to + call _async_waitpid instead of wait(), so that event loop recursion + is not triggered when the pid exit status is not yet available. + """ + if self._registered: + if event & self._exceptional_events: + self._log_poll_exception(event) + self._unregister() + self.cancel() + self._async_waitpid() + elif event & self.scheduler.IO_HUP: + self._unregister() + self._async_waitpid() + def _set_returncode(self, wait_retval): """ Set the returncode in a manner compatible with