From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id E645A1382A1 for ; Fri, 4 Jan 2013 07:07:22 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C08C4E05F9; Fri, 4 Jan 2013 07:07:15 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 35193E05F9 for ; Fri, 4 Jan 2013 07:07:15 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 23CE433DA01 for ; Fri, 4 Jan 2013 07:07:14 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 9B05BE5439 for ; Fri, 4 Jan 2013 07:07:12 +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: <1357283220.06d31ef00da24352a6614f20bccfc892d2120ed9.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: 06d31ef00da24352a6614f20bccfc892d2120ed9 X-VCS-Branch: master Date: Fri, 4 Jan 2013 07:07:12 +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: c964ac49-06eb-4241-90f5-59f17183685e X-Archives-Hash: 9cfd25bac76d5ad2f3054560eda4d705 commit: 06d31ef00da24352a6614f20bccfc892d2120ed9 Author: Zac Medico gentoo org> AuthorDate: Fri Jan 4 07:07:00 2013 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Jan 4 07:07:00 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=06d31ef0 ebuild-ipc: use PipeReader in _receive_reply --- bin/ebuild-ipc.py | 61 +++++----------------------------------------------- 1 files changed, 6 insertions(+), 55 deletions(-) diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py index e91c69c..ceab4d5 100755 --- a/bin/ebuild-ipc.py +++ b/bin/ebuild-ipc.py @@ -5,12 +5,10 @@ # This is a helper which ebuild processes can use # to communicate with portage's main python process. -import errno import logging import os import pickle import platform -import select import signal import sys import time @@ -49,7 +47,6 @@ class EbuildIpc(object): # Timeout for each individual communication attempt (we retry # as long as the daemon process appears to be alive). _COMMUNICATE_RETRY_TIMEOUT_SECONDS = 15 - _BUFSIZE = 4096 def __init__(self): self.fifo_dir = os.environ['PORTAGE_BUILDDIR'] @@ -148,41 +145,13 @@ class EbuildIpc(object): def _receive_reply(self, input_fd): - # Timeouts are handled by the parent process, so just - # block until input is available. For maximum portability, - # use a single atomic read. buf = None - while True: - try: - events = select.select([input_fd], [], []) - except select.error as e: - portage.util.writemsg_level( - "ebuild-ipc: %s: %s\n" % \ - (portage.localization._('during select for read'), e), - level=logging.ERROR, noiselevel=-1) - continue - if events[0]: - # For maximum portability, use os.read() here since - # array.fromfile() and file.read() are both known to - # erroneously return an empty string from this - # non-blocking fifo stream on FreeBSD (bug #337465). - try: - buf = os.read(input_fd, self._BUFSIZE) - except OSError as e: - if e.errno != errno.EAGAIN: - portage.util.writemsg_level( - "ebuild-ipc: %s: %s\n" % \ - (portage.localization._('read error'), e), - level=logging.ERROR, noiselevel=-1) - break - # Assume that another event will be generated - # if there's any relevant data. - continue - - # Only one (atomic) read should be necessary. - if buf: - break + pipe_reader = PipeReader(input_files={"input_fd":input_fd}, + scheduler=global_event_loop()) + pipe_reader.start() + pipe_reader.wait() + buf = pipe_reader.getvalue() retval = 2 @@ -272,25 +241,7 @@ class EbuildIpc(object): self._no_daemon_msg() return 2 - pr, pw = os.pipe() - pid = os.fork() - - if pid == 0: - retval = 2 - try: - os.close(pr) - retval = self._receive_reply(input_fd) - except SystemExit: - raise - except: - traceback.print_exc() - finally: - os._exit(retval) - - os.close(pw) - retval = self._wait(pid, pr, portage.localization._('during read')) - os.close(input_fd) - return retval + return self._receive_reply(input_fd) def ebuild_ipc_main(args): ebuild_ipc = EbuildIpc()