commit:     707a230042658e98b329c0a9141bc17d80a2f454
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 16 04:15:18 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jan 16 07:49:00 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=707a2300

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 <AT> gentoo.org>

 bin/socks5-server.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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:

Reply via email to