Skip to content

Commit

Permalink
🐛 Bug: Fix the bug where httpx.RemoteProtocolError was not caught
Browse files Browse the repository at this point in the history
  • Loading branch information
yym68686 committed Sep 12, 2024
1 parent 5c2c740 commit f4d6dda
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit f4d6dda

Please sign in to comment.