1 |
commit: 707a230042658e98b329c0a9141bc17d80a2f454 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jan 16 04:15:18 2019 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jan 16 07:49:00 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=707a2300 |
7 |
|
8 |
bin/socks5-server.py: fix PendingDeprecationWarning for asyncio.Task.current_task() |
9 |
|
10 |
PendingDeprecationWarning: Task.current_task() is deprecated, use asyncio.current_task() instead |
11 |
|
12 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
13 |
|
14 |
bin/socks5-server.py | 8 +++++++- |
15 |
1 file changed, 7 insertions(+), 1 deletion(-) |
16 |
|
17 |
diff --git a/bin/socks5-server.py b/bin/socks5-server.py |
18 |
index d46cf5345..f5d995f0d 100644 |
19 |
--- a/bin/socks5-server.py |
20 |
+++ b/bin/socks5-server.py |
21 |
@@ -17,6 +17,12 @@ else: |
22 |
# getattr() necessary because async is a keyword in Python >=3.7. |
23 |
asyncio_ensure_future = getattr(asyncio, 'async') |
24 |
|
25 |
+try: |
26 |
+ current_task = asyncio.current_task |
27 |
+except AttributeError: |
28 |
+ # Deprecated since Python 3.7 |
29 |
+ current_task = asyncio.Task.current_task |
30 |
+ |
31 |
|
32 |
class Socks5Server(object): |
33 |
""" |
34 |
@@ -154,7 +160,7 @@ class Socks5Server(object): |
35 |
# otherwise, start two loops: |
36 |
# remote -> local... |
37 |
t = asyncio_ensure_future(self.handle_proxied_conn( |
38 |
- proxied_reader, writer, asyncio.Task.current_task())) |
39 |
+ proxied_reader, writer, current_task())) |
40 |
|
41 |
# and local -> remote... |
42 |
try: |