diff --git a/src/routes/io/io.py b/src/routes/io/io.py index bcc7ed3..9499ea5 100644 --- a/src/routes/io/io.py +++ b/src/routes/io/io.py @@ -1,13 +1,15 @@ import io import time +import asyncio import puremagic -from typing import Annotated +from typing import Annotated,Optional from fastapi import ( APIRouter, 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()