From f5ee5db86faeb9fdf6545bcad5d7ebf2fc345680 Mon Sep 17 00:00:00 2001 From: Alexander Bersenev Date: Tue, 11 Feb 2020 19:10:43 +0500 Subject: [PATCH] use asyncio.all_tasks on new pythons --- mtprotoproxy.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mtprotoproxy.py b/mtprotoproxy.py index 284f97e..22a6bde 100755 --- a/mtprotoproxy.py +++ b/mtprotoproxy.py @@ -2260,7 +2260,13 @@ def main(): except KeyboardInterrupt: pass - for task in asyncio.Task.all_tasks(): + try: + tasks = asyncio.all_tasks(loop) + except AttributeError: + # for compatibility with python 3.6 + tasks = asyncio.Task.all_tasks(loop) + + for task in tasks: task.cancel() for server in servers: