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 2ADC813832E for ; Mon, 7 Jan 2013 09:16:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B437121C006; Mon, 7 Jan 2013 09:16:25 +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 35D9221C006 for ; Mon, 7 Jan 2013 09:16:25 +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 433C0335DF2 for ; Mon, 7 Jan 2013 09:16:24 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id D1597E5439 for ; Mon, 7 Jan 2013 09:16:22 +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: <1357550171.e132ec4f753b9df4769f7e58dfc661617c7375b8.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/process/, pym/portage/util/_async/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/tests/process/test_PopenProcess.py pym/portage/util/_async/PipeLogger.py X-VCS-Directories: pym/portage/tests/process/ pym/portage/util/_async/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: e132ec4f753b9df4769f7e58dfc661617c7375b8 X-VCS-Branch: master Date: Mon, 7 Jan 2013 09:16:22 +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: 3b11ec35-7c62-4531-94c8-489db2ae5e9b X-Archives-Hash: 2b953bcddf8bc06d1230fd67a56e214f commit: e132ec4f753b9df4769f7e58dfc661617c7375b8 Author: Zac Medico gentoo org> AuthorDate: Mon Jan 7 09:16:11 2013 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon Jan 7 09:16:11 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e132ec4f PipeLogger: handle file object for input_fd --- pym/portage/tests/process/test_PopenProcess.py | 7 ++----- pym/portage/util/_async/PipeLogger.py | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pym/portage/tests/process/test_PopenProcess.py b/pym/portage/tests/process/test_PopenProcess.py index 5ede164..88da0b3 100644 --- a/pym/portage/tests/process/test_PopenProcess.py +++ b/pym/portage/tests/process/test_PopenProcess.py @@ -1,4 +1,4 @@ -# Copyright 2012 Gentoo Foundation +# Copyright 2012-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import subprocess @@ -53,12 +53,9 @@ class PopenPipeTestCase(TestCase): try: consumer = PipeLogger(background=True, - input_fd=os.dup(producer.proc.stdout.fileno()), + input_fd=producer.proc.stdout, log_file_path=log_file_path) - # Close the stdout pipe, since we duplicated it, and it - # must be closed in order to avoid a ResourceWarning. - producer.proc.stdout.close() producer.pipe_reader = consumer producer.start() diff --git a/pym/portage/util/_async/PipeLogger.py b/pym/portage/util/_async/PipeLogger.py index 5464879..d0b1323 100644 --- a/pym/portage/util/_async/PipeLogger.py +++ b/pym/portage/util/_async/PipeLogger.py @@ -46,10 +46,15 @@ class PipeLogger(AbstractPollTask): else: fcntl_flags |= fcntl.FD_CLOEXEC - fcntl.fcntl(self.input_fd, fcntl.F_SETFL, - fcntl.fcntl(self.input_fd, fcntl.F_GETFL) | fcntl_flags) + if isinstance(self.input_fd, int): + fd = self.input_fd + else: + fd = self.input_fd.fileno() + + fcntl.fcntl(fd, fcntl.F_SETFL, + fcntl.fcntl(fd, fcntl.F_GETFL) | fcntl_flags) - self._reg_id = self.scheduler.io_add_watch(self.input_fd, + self._reg_id = self.scheduler.io_add_watch(fd, self._registered_events, self._output_handler) self._registered = True @@ -133,7 +138,10 @@ class PipeLogger(AbstractPollTask): self._reg_id = None if self.input_fd is not None: - os.close(self.input_fd) + if isinstance(self.input_fd, int): + os.close(self.input_fd) + else: + self.input_fd.close() self.input_fd = None if self.stdout_fd is not None: