From c04820cb35aee00dc1eef8a8ca7a0f032aa93c5c Mon Sep 17 00:00:00 2001 From: Rob Howley Date: Mon, 14 Oct 2024 14:21:14 -0400 Subject: [PATCH] fix: dont allow for new refresh threadpool tasks to start during shutdown Signed-off-by: Rob Howley --- sdk/python/feast/feature_server.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sdk/python/feast/feature_server.py b/sdk/python/feast/feature_server.py index 9757e95143..c188bd0d7b 100644 --- a/sdk/python/feast/feature_server.py +++ b/sdk/python/feast/feature_server.py @@ -85,11 +85,12 @@ def stop_refresh(): active_timer.cancel() def async_refresh(): + if shutting_down: + return + store.refresh_registry() nonlocal registry_proto registry_proto = store.registry.proto() - if shutting_down: - return if registry_ttl_sec: nonlocal active_timer @@ -222,8 +223,12 @@ def write_to_online_store(body=Depends(get_body)): ) @app.get("/health") - def health(): - return Response(status_code=status.HTTP_200_OK) + async def health(): + return ( + Response(status_code=status.HTTP_200_OK) + if registry_proto + else Response(status_code=status.HTTP_503_SERVICE_UNAVAILABLE) + ) @app.post("/materialize", dependencies=[Depends(inject_user_details)]) def materialize(body=Depends(get_body)):