From 1f3587e008dc7314a81db4cf998ea14f48d407ec Mon Sep 17 00:00:00 2001 From: gitee-cmd Date: Fri, 15 Oct 2021 10:07:57 +0800 Subject: [PATCH] fix asyncio_utils run in python3.7 --- mitmproxy/utils/asyncio_utils.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mitmproxy/utils/asyncio_utils.py b/mitmproxy/utils/asyncio_utils.py index 2feaaae..71972ab 100644 --- a/mitmproxy/utils/asyncio_utils.py +++ b/mitmproxy/utils/asyncio_utils.py @@ -29,37 +29,34 @@ def create_task( Ideally we stop closing the event loop during shutdown and then remove this parameter. """ try: - t = asyncio.create_task(coro, name=name) + t = asyncio.create_task(coro) except RuntimeError: if ignore_closed_loop: coro.close() return None else: raise - set_task_debug_info(t, name=name, client=client) + set_task_debug_info(t, client=client) return t def set_task_debug_info( task: asyncio.Task, *, - name: str, client: Optional[tuple] = None, ) -> None: """Set debug info for an externally-spawned task.""" task.created = time.time() # type: ignore - task.set_name(name) if client: task.client = client # type: ignore def task_repr(task: asyncio.Task) -> str: """Get a task representation with debug info.""" - name = task.get_name() age = getattr(task, "created", "") if age: age = f" (age: {time.time() - age:.0f}s)" client = getattr(task, "client", "") if client: client = f"{human.format_address(client)}: " - return f"{client}{name}{age}" + return f"{client}{age}" -- 2.30.0