From f4d6dda66918acd0614d4a974f2fa395dc0b36ba Mon Sep 17 00:00:00 2001 From: yym68686 Date: Thu, 12 Sep 2024 17:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Bug:=20Fix=20the=20bug=20where?= =?UTF-8?q?=20httpx.RemoteProtocolError=20was=20not=20caught?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index ddbb223..31cf49e 100644 --- a/main.py +++ b/main.py @@ -228,7 +228,7 @@ async def process_request(request: Union[RequestModel, ImageGenerationRequest], app.middleware_stack.app.channel_success_counts[provider['provider']] += 1 return response - except (Exception, HTTPException, asyncio.CancelledError, httpx.ReadError) as e: + except (Exception, HTTPException, asyncio.CancelledError, httpx.ReadError, httpx.RemoteProtocolError) as e: # 更新失败计数 async with app.middleware_stack.app.lock: app.middleware_stack.app.channel_failure_counts[provider['provider']] += 1 @@ -388,7 +388,7 @@ async def try_all_providers(self, request: Union[RequestModel, ImageGenerationRe continue else: raise HTTPException(status_code=500, detail=f"Error: Current provider response failed: {error_message}") - except (Exception, asyncio.CancelledError, httpx.ReadError) as e: + except (Exception, asyncio.CancelledError, httpx.ReadError, httpx.RemoteProtocolError) as e: logger.error(f"Error with provider {provider['provider']}: {str(e)}") error_message = str(e) if auto_retry: