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 8DB341382C5 for ; Sun, 29 Apr 2018 06:09:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8F9E9E083D; Sun, 29 Apr 2018 06:09:13 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 63768E083D for ; Sun, 29 Apr 2018 06:09:13 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (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 CE441335C9C for ; Sun, 29 Apr 2018 06:09:10 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 02D93288 for ; Sun, 29 Apr 2018 06:09:09 +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: <1524981538.be800bf0153a28ce034277d103a2021f93ac8b2e.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_async/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/util/_async/PopenProcess.py X-VCS-Directories: pym/portage/util/_async/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: be800bf0153a28ce034277d103a2021f93ac8b2e X-VCS-Branch: master Date: Sun, 29 Apr 2018 06:09:09 +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: 13919200-3b4d-4ec8-8e8c-df11fd8f05a2 X-Archives-Hash: 81116111bfb2e9e4bdd12fcb462d6cb8 commit: be800bf0153a28ce034277d103a2021f93ac8b2e Author: Zac Medico gentoo org> AuthorDate: Sun Apr 29 05:10:27 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Apr 29 05:58:58 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=be800bf0 PopenProcess: add_child_handler asyncio compat (bug 591760) Migrate to asyncio's AbstractChildWatcher.add_child_handler interface. Bug: https://bugs.gentoo.org/591760 pym/portage/util/_async/PopenProcess.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/pym/portage/util/_async/PopenProcess.py b/pym/portage/util/_async/PopenProcess.py index 4344b1c9d..3fb60d527 100644 --- a/pym/portage/util/_async/PopenProcess.py +++ b/pym/portage/util/_async/PopenProcess.py @@ -1,4 +1,4 @@ -# Copyright 2012-2017 Gentoo Foundation +# Copyright 2012-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from _emerge.SubProcess import SubProcess @@ -13,8 +13,7 @@ class PopenProcess(SubProcess): self._registered = True if self.pipe_reader is None: - self._reg_id = self.scheduler.child_watch_add( - self.pid, self._child_watch_cb) + self._async_waitpid() else: try: self.pipe_reader.scheduler = self.scheduler @@ -24,17 +23,25 @@ class PopenProcess(SubProcess): self.pipe_reader.start() def _pipe_reader_exit(self, pipe_reader): - self._reg_id = self.scheduler.child_watch_add( - self.pid, self._child_watch_cb) + self._async_waitpid() - def _child_watch_cb(self, pid, condition, user_data=None): - self._reg_id = None - self._waitpid_cb(pid, condition) - self.wait() + def _async_waitpid(self): + if self.returncode is None: + self.scheduler._asyncio_child_watcher.\ + add_child_handler(self.pid, self._async_waitpid_cb) + else: + self._unregister() + self._async_wait() - def _set_returncode(self, wait_retval): - SubProcess._set_returncode(self, wait_retval) + def _async_waitpid_cb(self, pid, returncode): if self.proc.returncode is None: # Suppress warning messages like this: # ResourceWarning: subprocess 1234 is still running - self.proc.returncode = self.returncode + self.proc.returncode = returncode + self._unregister() + self.returncode = returncode + self._async_wait() + + def _poll(self): + # Simply rely on _async_waitpid_cb to set the returncode. + return self.returncode