Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/litserve/loops/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def populate_context(self, lit_spec: LitSpec, request: Any):
def put_response(
self, response_queues: List[Queue], response_queue_id: int, uid: str, response_data: Any, status: LitAPIStatus
) -> None:
# response_data = pickle.dumps(response_data)
if self.producer:
self.producer.put((uid, (response_data, status)), consumer_id=response_queue_id)
else:
Expand Down
18 changes: 18 additions & 0 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,21 @@ def test_concurrent_requests(lit_server):
assert response.json() == {"output": i**2}, "Server returns square of the input number"
count += 1
assert count == n_requests


class CustomError(Exception):
def __init__(self, arg1, arg2, arg3):
super().__init__("Test exception")


class ExceptionAPI(SimpleLitAPI):
def predict(self, x):
raise CustomError("This", "is", "a test")


def test_exception():
server = LitServer(ExceptionAPI(), accelerator="cpu", devices=1)
with wrap_litserve_start(server) as server, TestClient(server.app) as client:
response = client.post("/predict", json={"input": 4.0})
assert response.status_code == 500
assert response.json() == {"detail": "Internal Server Error"}
Loading