commit:     0b11ac9ce296367699e1a191b87be22612b266ff
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 19 00:44:57 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jan 19 00:45:17 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=0b11ac9c

ProxyManager: Use async and await syntax

Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/tests/util/test_socks5.py | 4 ++--
 lib/portage/util/socks5.py            | 9 +++------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/portage/tests/util/test_socks5.py 
b/lib/portage/tests/util/test_socks5.py
index 44d522013..82cf93fe8 100644
--- a/lib/portage/tests/util/test_socks5.py
+++ b/lib/portage/tests/util/test_socks5.py
@@ -1,4 +1,4 @@
-# Copyright 2019 Gentoo Authors
+# Copyright 2019-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import functools
@@ -185,7 +185,7 @@ class Socks5ServerTestCase(TestCase):
                                }
 
                                proxy = socks5.get_socks5_proxy(settings)
-                               
loop.run_until_complete(socks5.proxy.ready(loop=loop))
+                               loop.run_until_complete(socks5.proxy.ready())
 
                                result = 
loop.run_until_complete(loop.run_in_executor(None,
                                        self._fetch_via_proxy, proxy, host, 
server.server_port, path))

diff --git a/lib/portage/util/socks5.py b/lib/portage/util/socks5.py
index a76d1a741..ddf6bb4d0 100644
--- a/lib/portage/util/socks5.py
+++ b/lib/portage/util/socks5.py
@@ -1,5 +1,5 @@
 # SOCKSv5 proxy manager for network-sandbox
-# Copyright 2015-2020 Gentoo Authors
+# Copyright 2015-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import errno
@@ -11,7 +11,6 @@ import portage.data
 from portage import _python_interpreter
 from portage.data import portage_gid, portage_uid, userpriv_groups
 from portage.process import atexit_register, spawn
-from portage.util.futures.compat_coroutine import coroutine
 from portage.util.futures import asyncio
 
 class ProxyManager:
@@ -74,9 +73,7 @@ class ProxyManager:
                """
                return self.socket_path is not None
 
-
-       @coroutine
-       def ready(self, loop=None):
+       async def ready(self, loop=None):
                """
                Wait for the proxy socket to become ready. This method is a 
coroutine.
                """
@@ -98,7 +95,7 @@ class ProxyManager:
                        except EnvironmentError as e:
                                if e.errno != errno.ENOENT:
                                        raise
-                               yield asyncio.sleep(0.2, loop=loop)
+                               await asyncio.sleep(0.2)
                        else:
                                break
                        finally:

Reply via email to