From fb621da2182aacca7ce25a1eba02d2315600981f Mon Sep 17 00:00:00 2001 From: aditya047-stack Date: Tue, 17 Mar 2026 13:05:56 +0530 Subject: [PATCH 1/4] fix: adding Optional import explicitly in io.py --- src/routes/io/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/io/io.py b/src/routes/io/io.py index bcc7ed3..a4e0ac4 100644 --- a/src/routes/io/io.py +++ b/src/routes/io/io.py @@ -1,7 +1,7 @@ import io import time import puremagic -from typing import Annotated +from typing import Annotated,Optional from fastapi import ( APIRouter, File, From 031a4103ac69447ef97f6bc1301045ed262d9ba6 Mon Sep 17 00:00:00 2001 From: aditya047-stack Date: Tue, 17 Mar 2026 14:38:49 +0530 Subject: [PATCH 2/4] fix: Added asyncio.sleep and imported HTTPException from FastAPI for better error handling of 400 error in '/delay' endpoint in io.py --- src/routes/io/io.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/routes/io/io.py b/src/routes/io/io.py index a4e0ac4..9499ea5 100644 --- a/src/routes/io/io.py +++ b/src/routes/io/io.py @@ -1,5 +1,6 @@ import io import time +import asyncio import puremagic from typing import Annotated,Optional from fastapi import ( @@ -7,7 +8,8 @@ File, UploadFile, Form, - Request + Request, + HTTPException ) from models.responses import * from foss42.text.slugify import slugify @@ -21,8 +23,11 @@ async def delayed_request(wait: int = 5): try: if wait > 120: raise bad_request_400(msg="Delay cannot be more than 120 secs") - time.sleep(wait) + await asyncio.sleep(wait) return ok_200(f"Waited for {wait} seconds") + + except HTTPException: + raise except Exception as e: raise internal_error_500() From 85772086b70890532ccb9ebaaa17ffe0bb42e019 Mon Sep 17 00:00:00 2001 From: aditya047-stack Date: Tue, 17 Mar 2026 14:45:17 +0530 Subject: [PATCH 3/4] Revert "fix: Added asyncio.sleep and imported HTTPException from FastAPI for better error handling of 400 error in '/delay' endpoint in io.py" This reverts commit 031a4103ac69447ef97f6bc1301045ed262d9ba6. --- src/routes/io/io.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/routes/io/io.py b/src/routes/io/io.py index 9499ea5..a4e0ac4 100644 --- a/src/routes/io/io.py +++ b/src/routes/io/io.py @@ -1,6 +1,5 @@ import io import time -import asyncio import puremagic from typing import Annotated,Optional from fastapi import ( @@ -8,8 +7,7 @@ File, UploadFile, Form, - Request, - HTTPException + Request ) from models.responses import * from foss42.text.slugify import slugify @@ -23,11 +21,8 @@ async def delayed_request(wait: int = 5): try: if wait > 120: raise bad_request_400(msg="Delay cannot be more than 120 secs") - await asyncio.sleep(wait) + time.sleep(wait) return ok_200(f"Waited for {wait} seconds") - - except HTTPException: - raise except Exception as e: raise internal_error_500() From ded4694b63e03e3737e10fb6014702e010b76e31 Mon Sep 17 00:00:00 2001 From: aditya047-stack Date: Tue, 17 Mar 2026 14:58:43 +0530 Subject: [PATCH 4/4] fix: Original---- Added asyncio.sleep and imported HTTPException from FastAPI for better error handling of 400 error in '/delay' endpoint in io.py --- src/routes/io/io.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/routes/io/io.py b/src/routes/io/io.py index a4e0ac4..6961cab 100644 --- a/src/routes/io/io.py +++ b/src/routes/io/io.py @@ -1,4 +1,5 @@ import io +import asyncio import time import puremagic from typing import Annotated,Optional @@ -7,12 +8,14 @@ File, UploadFile, Form, - Request + Request, + HTTPException ) from models.responses import * from foss42.text.slugify import slugify import foss42.text.humanize as hz + io_router = APIRouter(tags=["I/O"]) @@ -21,8 +24,10 @@ async def delayed_request(wait: int = 5): try: if wait > 120: raise bad_request_400(msg="Delay cannot be more than 120 secs") - time.sleep(wait) + await asyncio.sleep(wait) return ok_200(f"Waited for {wait} seconds") + except HTTPException: + raise except Exception as e: raise internal_error_500()