public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_async/
Date: Sun, 29 Apr 2018 06:09:09 +0000 (UTC)	[thread overview]
Message-ID: <1524981538.be800bf0153a28ce034277d103a2021f93ac8b2e.zmedico@gentoo> (raw)

commit:     be800bf0153a28ce034277d103a2021f93ac8b2e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 29 05:10:27 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> 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


             reply	other threads:[~2018-04-29  6:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-29  6:09 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-14 15:37 [gentoo-commits] proj/portage:master commit in: pym/portage/util/_async/ Zac Medico
2018-04-30  6:29 Zac Medico
2018-04-29 22:24 Zac Medico
2018-04-29  4:12 Zac Medico
2018-04-28 23:29 Zac Medico
2018-04-28 23:20 Zac Medico
2018-04-28 23:08 Zac Medico
2018-04-26  9:37 Zac Medico
2018-04-26  8:06 Zac Medico
2018-04-26  5:49 Zac Medico
2018-04-23  1:03 Zac Medico
2018-04-22 17:50 Zac Medico
2018-04-19  6:28 Zac Medico
2017-02-08  9:39 Zac Medico
2013-07-07  2:17 Zac Medico
2013-01-05 15:20 Zac Medico
2013-01-05  3:41 Zac Medico
2012-12-29  7:45 Zac Medico
2012-10-18  1:24 Zac Medico
2012-10-16  6:51 Zac Medico
2012-10-08 13:49 Zac Medico
2012-10-06  1:54 Zac Medico
2012-10-03 18:56 Zac Medico
2012-10-03 18:39 Zac Medico
2012-10-03 17:40 Zac Medico
2012-10-03 10:19 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1524981538.be800bf0153a28ce034277d103a2021f93ac8b2e.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox