From f2d6ec3169611595cc30b426dd147de05d3fea44 Mon Sep 17 00:00:00 2001 From: John Xina Date: Mon, 19 Feb 2024 22:18:00 +0800 Subject: [PATCH] Backport proxify to older python version --- proxify.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/proxify.py b/proxify.py index 8839a8a..3d20f11 100644 --- a/proxify.py +++ b/proxify.py @@ -99,13 +99,12 @@ class Asgiproxify(): }) async for chunk, _ in resp.content.iter_chunks(): try: - async with asyncio.timeout(10): - await send({ - 'type': 'http.response.body', - 'body': chunk, - 'more_body': True, - }) - except TimeoutError: + await asyncio.wait_for(send({ + 'type': 'http.response.body', + 'body': chunk, + 'more_body': True, + }), timeout=10) + except asyncio.TimeoutError: return await send({'type': 'http.response.body'})