Skip to content

Commit

Permalink
remove dead code (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketmaurya authored Aug 12, 2024
1 parent 939a03d commit f472c5c
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions src/litserve/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
import asyncio
import logging
import pickle
import uuid
from typing import Coroutine, Optional
from typing import Optional
from contextlib import contextmanager
from typing import TYPE_CHECKING


from fastapi import HTTPException
from starlette.middleware.base import BaseHTTPMiddleware

Expand All @@ -37,24 +35,6 @@ class LitAPIStatus:
FINISH_STREAMING = "FINISH_STREAMING"


async def wait_for_queue_timeout(coro: Coroutine, timeout: Optional[float], uid: uuid.UUID, request_buffer: dict):
if timeout == -1 or timeout is False:
return await coro

task = asyncio.create_task(coro)
shield = asyncio.shield(task)
try:
return await asyncio.wait_for(shield, timeout)
except asyncio.TimeoutError:
if uid in request_buffer:
logger.error(
f"Request was waiting in the queue for too long ({timeout} seconds) and has been timed out. "
"You can adjust the timeout by providing the `timeout` argument to LitServe(..., timeout=30)."
)
raise HTTPException(504, "Request timed out")
return await task


def load_and_raise(response):
try:
exception = pickle.loads(response) if isinstance(response, bytes) else response
Expand Down

0 comments on commit f472c5c

Please sign in to comment.