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 7B0B61382C5 for ; Wed, 11 Apr 2018 01:47:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B23B8E0B93; Wed, 11 Apr 2018 01:47:10 +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 924F8E0B93 for ; Wed, 11 Apr 2018 01:47:09 +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 28810335C60 for ; Wed, 11 Apr 2018 01:47:08 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 85757285 for ; Wed, 11 Apr 2018 01:47:06 +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: <1523411074.82759203b9b39389de9ab27aeae58319b604f1ae.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/dbapi/porttree.py X-VCS-Directories: pym/portage/dbapi/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 82759203b9b39389de9ab27aeae58319b604f1ae X-VCS-Branch: master Date: Wed, 11 Apr 2018 01:47:06 +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: da24f6cb-42e9-43a5-aa3e-c89d7d6fb166 X-Archives-Hash: ad0c9637d95b259ae281d6cf8203f39d commit: 82759203b9b39389de9ab27aeae58319b604f1ae Author: Zac Medico gentoo org> AuthorDate: Tue Apr 10 15:16:21 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Apr 11 01:44:34 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=82759203 async_aux_get: support asyncio via _PortageEventLoopPolicy (bug 649588) Support portage's internal EventLoop as well as the _PortageEventLoop asyncio compatibility wrapper, by using the respective _loop and _asyncio_wrapper attributes where appropriate. Example usage for coroutine with PEP 492 async and await syntax: import asyncio import portage from portage.exception import PortageKeyError from portage.util.futures.unix_events import DefaultEventLoopPolicy asyncio.set_event_loop_policy(DefaultEventLoopPolicy()) async def aux_get_demo(): portdb = portage.portdb for cpv in portdb.cp_list('sys-apps/portage'): try: result = await portdb.async_aux_get(cpv, portage.auxdbkeys) except PortageKeyError as e: # aux_get failed print('error:', cpv, e) else: print(cpv, result) asyncio.get_event_loop().run_until_complete(aux_get_demo()) Bug: https://bugs.gentoo.org/649588 pym/portage/dbapi/porttree.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 910e90e6f..951e5760a 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -611,6 +611,7 @@ class portdbapi(dbapi): # Callers of this method certainly want the same event loop to # be used for all calls. loop = loop or global_event_loop() + loop = getattr(loop, '_asyncio_wrapper', loop) future = loop.create_future() cache_me = False if myrepo is not None: @@ -665,7 +666,7 @@ class portdbapi(dbapi): proc = EbuildMetadataPhase(cpv=mycpv, ebuild_hash=ebuild_hash, portdb=self, - repo_path=mylocation, scheduler=loop, + repo_path=mylocation, scheduler=loop._loop, settings=self.doebuild_settings) proc.addExitListener(functools.partial(self._aux_get_return,