aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2021-01-18 16:44:57 -0800
committerZac Medico <zmedico@gentoo.org>2021-01-18 16:45:17 -0800
commit0b11ac9ce296367699e1a191b87be22612b266ff (patch)
tree81db0a2e96ceab2968721acd9a0107efb60b8987
parentman/make.conf.5: Fix typo in markup (diff)
downloadportage-0b11ac9ce296367699e1a191b87be22612b266ff.tar.gz
portage-0b11ac9ce296367699e1a191b87be22612b266ff.tar.bz2
portage-0b11ac9ce296367699e1a191b87be22612b266ff.zip
ProxyManager: Use async and await syntax
Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r--lib/portage/tests/util/test_socks5.py4
-rw-r--r--lib/portage/util/socks5.py9
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: