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 5305713835B for ; Sun, 7 Mar 2021 15:17:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4E447E0844; Sun, 7 Mar 2021 15:17:42 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 346BCE0843 for ; Sun, 7 Mar 2021 15:17:42 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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 C18F8340942 for ; Sun, 7 Mar 2021 15:17:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B97A14F1 for ; Sun, 7 Mar 2021 15:17:33 +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: <1615127866.9eea2af22c9e51475a4adba57fdded3a2a88c886.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/util/futures/_asyncio/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/util/futures/_asyncio/streams.py X-VCS-Directories: lib/portage/util/futures/_asyncio/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 9eea2af22c9e51475a4adba57fdded3a2a88c886 X-VCS-Branch: master Date: Sun, 7 Mar 2021 15:17:33 +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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 1c5767be-d295-45b5-9de7-b5e2a1089303 X-Archives-Hash: c0a862f19526fba47f6296ff3087346e commit: 9eea2af22c9e51475a4adba57fdded3a2a88c886 Author: Zac Medico gentoo org> AuthorDate: Sun Mar 7 14:18:44 2021 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Mar 7 14:37:46 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9eea2af2 _writer: Use async and await syntax Signed-off-by: Zac Medico gentoo.org> lib/portage/util/futures/_asyncio/streams.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/portage/util/futures/_asyncio/streams.py b/lib/portage/util/futures/_asyncio/streams.py index ea5882dd3..7a8d4a3e0 100644 --- a/lib/portage/util/futures/_asyncio/streams.py +++ b/lib/portage/util/futures/_asyncio/streams.py @@ -1,4 +1,4 @@ -# Copyright 2018-2020 Gentoo Authors +# Copyright 2018-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import errno @@ -9,7 +9,6 @@ portage.proxy.lazyimport.lazyimport(globals(), '_emerge.PipeReader:PipeReader', 'portage.util.futures:asyncio', ) -from portage.util.futures.compat_coroutine import coroutine def _reader(input_file, loop=None): @@ -55,8 +54,7 @@ class _Reader: self._pipe_reader = None -@coroutine -def _writer(output_file, content, loop=None): +async def _writer(output_file, content, loop=DeprecationWarning): """ Asynchronously write bytes to output file. The output file is assumed to be in non-blocking mode. If an EnvironmentError @@ -68,10 +66,9 @@ def _writer(output_file, content, loop=None): @type output_file: file object @param content: content to write @type content: bytes - @param loop: asyncio.AbstractEventLoop (or compatible) - @type loop: event loop + @param loop: deprecated """ - loop = asyncio._wrap_loop(loop) + loop = asyncio.get_event_loop() fd = output_file.fileno() while content: try: @@ -82,7 +79,7 @@ def _writer(output_file, content, loop=None): waiter = loop.create_future() loop.add_writer(fd, lambda: waiter.done() or waiter.set_result(None)) try: - yield waiter + await waiter finally: # The loop and output file may have been closed. if not loop.is_closed():