fix asyncio utils run in python3.7

This commit is contained in:
gitee-cmd 2021-10-15 09:52:00 +08:00
parent ac07069d0c
commit fdaef0a5a4
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,57 @@
From 1f3587e008dc7314a81db4cf998ea14f48d407ec Mon Sep 17 00:00:00 2001
From: gitee-cmd <chemingdao@huawei.com>
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

View File

@ -1,13 +1,14 @@
%global _empty_manifest_terminate_build 0
Name: python-mitmproxy
Version: 7.0.0
Release: 3
Release: 4
Summary: An interactive, SSL/TLS-capable intercepting proxy for HTTP/1, HTTP/2, and WebSockets.
License: MIT
URL: https://github.com/mitmproxy/mitmproxy/
Source0: https://github.com/mitmproxy/mitmproxy/archive/refs/tags/v%{version}.tar.gz
Patch0: fix-build-fail-with-python3.7.patch
Patch0001: 0001-fix-run-in-python-3.7-environment.patch
Patch0002: 0002-fix-asyncio_utils-run-in-python3.7.patch
BuildArch: noarch
Requires: python3-asgiref python3-blinker python3-Brotli python3-certifi python3-click
Requires: python3-cryptography python3-flask python3-h11 python3-h2 python3-hyperframe
@ -76,6 +77,9 @@ mv %{buildroot}/doclist.lst .
%{_docdir}/*
%changelog
* Fri Oct 15 2021 chemingdao <chemingdao@huawei.com> - 7.0.0-4
- fix asynocio utils run in python3.7
* Thu Sep 30 2021 chemingdao <chemingdao@huawei.com> - 7.0.0-3
- fix run in python 3.7 environment