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 407D6138331 for ; Mon, 30 Apr 2018 06:29:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 27C56E0BEE; Mon, 30 Apr 2018 06:29:29 +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 E8084E0BE9 for ; Mon, 30 Apr 2018 06:29:28 +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 97CBA335C78 for ; Mon, 30 Apr 2018 06:29:27 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0DC7929B for ; Mon, 30 Apr 2018 06:29:26 +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: <1525068692.452018c1fbf76cf097dbee1a9bb22a8b97958014.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/ebuild-ipc.py X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 452018c1fbf76cf097dbee1a9bb22a8b97958014 X-VCS-Branch: master Date: Mon, 30 Apr 2018 06:29:26 +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: 72b353a5-225d-43f9-bd57-7a5ae8f031de X-Archives-Hash: e84e953d27709116967ce0b3eafa7b28 commit: 452018c1fbf76cf097dbee1a9bb22a8b97958014 Author: Zac Medico gentoo org> AuthorDate: Mon Apr 30 02:30:29 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon Apr 30 06:11:32 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=452018c1 FifoWriter: add_writer asyncio compat (bug 654382) Use add_writer for asyncio compatibility. Bug: https://bugs.gentoo.org/654382 bin/ebuild-ipc.py | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py index b47ee2333..c2773cb6a 100755 --- a/bin/ebuild-ipc.py +++ b/bin/ebuild-ipc.py @@ -1,5 +1,5 @@ #!/usr/bin/python -b -# Copyright 2010-2014 Gentoo Foundation +# Copyright 2010-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # # This is a helper which ebuild processes can use @@ -53,7 +53,7 @@ RETURNCODE_WRITE_FAILED = 2 class FifoWriter(AbstractPollTask): - __slots__ = ('buf', 'fifo', '_fd', '_reg_id',) + __slots__ = ('buf', 'fifo', '_fd') def _start(self): try: @@ -67,31 +67,27 @@ class FifoWriter(AbstractPollTask): return else: raise - self._reg_id = self.scheduler.io_add_watch( + self.scheduler.add_writer( self._fd, - self.scheduler.IO_OUT | self.scheduler.IO_HUP | \ - self._exceptional_events, self._output_handler) + self._output_handler) self._registered = True - def _output_handler(self, fd, event): - if event & self.scheduler.IO_OUT: - # The whole buf should be able to fit in the fifo with - # a single write call, so there's no valid reason for - # os.write to raise EAGAIN here. - buf = self.buf - while buf: + def _output_handler(self): + # The whole buf should be able to fit in the fifo with + # a single write call, so there's no valid reason for + # os.write to raise EAGAIN here. + fd = self._fd + buf = self.buf + while buf: + try: buf = buf[os.write(fd, buf):] - self.returncode = os.EX_OK - self._unregister() - self.wait() - return False - else: - self._unregister_if_appropriate(event) - if not self._registered: + except EnvironmentError: self.returncode = RETURNCODE_WRITE_FAILED - self.wait() - return False - return True + self._async_wait() + return + + self.returncode = os.EX_OK + self._async_wait() def _cancel(self): self.returncode = self._cancelled_returncode @@ -99,10 +95,8 @@ class FifoWriter(AbstractPollTask): def _unregister(self): self._registered = False - if self._reg_id is not None: - self.scheduler.source_remove(self._reg_id) - self._reg_id = None if self._fd is not None: + self.scheduler.remove_writer(self._fd) os.close(self._fd) self._fd = None