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: Mon, 30 Apr 2018 06:29:26 +0000 (UTC)	[thread overview]
Message-ID: <1525069201.2495fe6ff060e2ed8ee54e08a4dec132de1f4984.zmedico@gentoo> (raw)

commit:     2495fe6ff060e2ed8ee54e08a4dec132de1f4984
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 30 05:52:07 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Apr 30 06:20:01 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=2495fe6f

PipeLogger: add_reader asyncio compat (bug 654382)

Use add_reader for asyncio compatibility.

Bug: https://bugs.gentoo.org/654382

 pym/portage/util/_async/PipeLogger.py | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/pym/portage/util/_async/PipeLogger.py b/pym/portage/util/_async/PipeLogger.py
index 02de74b16..61000271d 100644
--- a/pym/portage/util/_async/PipeLogger.py
+++ b/pym/portage/util/_async/PipeLogger.py
@@ -21,7 +21,7 @@ class PipeLogger(AbstractPollTask):
 	"""
 
 	__slots__ = ("input_fd", "log_file_path", "stdout_fd") + \
-		("_log_file", "_log_file_real", "_reg_id")
+		("_log_file", "_log_file_real")
 
 	def _start(self):
 
@@ -57,8 +57,7 @@ class PipeLogger(AbstractPollTask):
 				fcntl.fcntl(fd, fcntl.F_SETFD,
 					fcntl.fcntl(fd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
 
-		self._reg_id = self.scheduler.io_add_watch(fd,
-			self._registered_events, self._output_handler)
+		self.scheduler.add_reader(fd, self._output_handler, fd)
 		self._registered = True
 
 	def _cancel(self):
@@ -66,14 +65,14 @@ class PipeLogger(AbstractPollTask):
 		if self.returncode is None:
 			self.returncode = self._cancelled_returncode
 
-	def _output_handler(self, fd, event):
+	def _output_handler(self, fd):
 
 		background = self.background
 		stdout_fd = self.stdout_fd
 		log_file = self._log_file 
 
 		while True:
-			buf = self._read_buf(fd, event)
+			buf = self._read_buf(fd, None)
 
 			if buf is None:
 				# not a POLLIN event, EAGAIN, etc...
@@ -124,20 +123,13 @@ class PipeLogger(AbstractPollTask):
 					log_file.write(buf)
 					log_file.flush()
 
-		self._unregister_if_appropriate(event)
-
-		return True
-
 	def _unregister(self):
-
-		if self._reg_id is not None:
-			self.scheduler.source_remove(self._reg_id)
-			self._reg_id = None
-
 		if self.input_fd is not None:
 			if isinstance(self.input_fd, int):
+				self.scheduler.remove_reader(self.input_fd)
 				os.close(self.input_fd)
 			else:
+				self.scheduler.remove_reader(self.input_fd.fileno())
 				self.input_fd.close()
 			self.input_fd = None
 


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

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30  6:29 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-29 22:24 Zac Medico
2018-04-29  6:09 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=1525069201.2495fe6ff060e2ed8ee54e08a4dec132de1f4984.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