aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2019-01-15 20:15:18 -0800
committerZac Medico <zmedico@gentoo.org>2019-01-15 23:49:00 -0800
commit707a230042658e98b329c0a9141bc17d80a2f454 (patch)
tree3334980694bd90b99558964fc7c1220554ff509f
parenttests: add unit test for portage.util.socks5 (FEATURES=network-sandbox-proxy) (diff)
downloadportage-707a2300.tar.gz
portage-707a2300.tar.bz2
portage-707a2300.zip
bin/socks5-server.py: fix PendingDeprecationWarning for asyncio.Task.current_task()
PendingDeprecationWarning: Task.current_task() is deprecated, use asyncio.current_task() instead Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r--bin/socks5-server.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/bin/socks5-server.py b/bin/socks5-server.py
index d46cf5345..f5d995f0d 100644
--- a/bin/socks5-server.py
+++ b/bin/socks5-server.py
@@ -17,6 +17,12 @@ else:
# getattr() necessary because async is a keyword in Python >=3.7.
asyncio_ensure_future = getattr(asyncio, 'async')
+try:
+ current_task = asyncio.current_task
+except AttributeError:
+ # Deprecated since Python 3.7
+ current_task = asyncio.Task.current_task
+
class Socks5Server(object):
"""
@@ -154,7 +160,7 @@ class Socks5Server(object):
# otherwise, start two loops:
# remote -> local...
t = asyncio_ensure_future(self.handle_proxied_conn(
- proxied_reader, writer, asyncio.Task.current_task()))
+ proxied_reader, writer, current_task()))
# and local -> remote...
try: