From ff267c32961ddc8fe8215b1d3e271286679d2c7e Mon Sep 17 00:00:00 2001 From: Jakub Orchowski Date: Sun, 27 Oct 2024 19:13:15 +0100 Subject: [PATCH] first stop, then throw exception --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 7ad2015..b67586b 100644 --- a/main.py +++ b/main.py @@ -54,10 +54,10 @@ async def read_item(request: LinkRequest): challenged = await asyncio.wait_for(bypass_cloudflare(page), timeout=timeout) except asyncio.TimeoutError as e: logger.info("Timed out bypassing Cloudflare") + browser.stop() raise HTTPException( detail="Timed out bypassing Cloudflare", status_code=408 ) from e - browser.stop() except Exception as e: browser.stop() raise HTTPException(detail="Couldn't bypass", status_code=500) from e