Skip to content

Commit 063eeb2

Browse files
fix: Address review feedback for async event loop and API compatibility
1. Wrap response_to_dict_fast in run_in_threadpool to avoid blocking the async event loop during CPU-bound serialization (fixes concurrency under high load) 2. Omit event_timestamps key when empty to match MessageToDict behavior (API compatibility - MessageToDict omits empty repeated fields) Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c5eef73 commit 063eeb2

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

sdk/python/feast/feature_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ async def get_online_features(request: GetOnlineFeaturesRequest) -> ORJSONRespon
341341
lambda: store.get_online_features(**read_params) # type: ignore
342342
)
343343

344-
response_dict = response_to_dict_fast(response.proto)
344+
response_dict = await run_in_threadpool(response_to_dict_fast, response.proto)
345345
return ORJSONResponse(content=response_dict)
346346

347347
@app.post(
@@ -370,7 +370,7 @@ async def retrieve_online_documents(
370370
lambda: store.retrieve_online_documents(**read_params) # type: ignore
371371
)
372372

373-
response_dict = response_to_dict_fast(response.proto)
373+
response_dict = await run_in_threadpool(response_to_dict_fast, response.proto)
374374
return ORJSONResponse(content=response_dict)
375375

376376
@app.post("/push", dependencies=[Depends(inject_user_details)])

sdk/python/feast/feature_server_utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@ def response_to_dict_fast(response: GetOnlineFeaturesResponse) -> Dict[str, Any]
2929
"statuses": [
3030
_STATUS_NAMES.get(s, "INVALID") for s in feature_vector.statuses
3131
],
32-
"event_timestamps": [
33-
_timestamp_to_str(ts) for ts in feature_vector.event_timestamps
34-
]
35-
if feature_vector.event_timestamps
36-
else [],
32+
**(
33+
{
34+
"event_timestamps": [
35+
_timestamp_to_str(ts)
36+
for ts in feature_vector.event_timestamps
37+
]
38+
}
39+
if feature_vector.event_timestamps
40+
else {}
41+
),
3742
}
3843
for feature_vector in response.results
3944
]

0 commit comments

Comments
 (0)