Skip to content

Commit 8a0cb98

Browse files
ikaadilYuhanLiu11
andauthored
Refactor request handling to optimize JSON parsing by replacing await with json.loads for improved performance. (#629)
Signed-off-by: Ifta Khairul Alam Adil <[email protected]> Co-authored-by: Yuhan Liu <[email protected]>
1 parent f5205ce commit 8a0cb98

File tree

1 file changed

+1
-2
lines changed
  • src/vllm_router/services/request_service

1 file changed

+1
-2
lines changed

src/vllm_router/services/request_service/request.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ async def route_general_request(
163163
# Same as vllm, Get request_id from X-Request-Id header if available
164164
request_id = request.headers.get("X-Request-Id") or str(uuid.uuid4())
165165
request_body = await request.body()
166-
request_json = await request.json() # TODO (ApostaC): merge two awaits into one
166+
request_json = json.loads(request_body)
167167

168168
if request.query_params:
169169
request_endpoint = request.query_params.get("id")
@@ -203,7 +203,6 @@ async def route_general_request(
203203
status_code=400, detail="Request body is not JSON parsable."
204204
)
205205

206-
# TODO (ApostaC): merge two awaits into one
207206
service_discovery = get_service_discovery()
208207
endpoints = service_discovery.get_endpoint_info()
209208

0 commit comments

Comments
 (0)