Skip to content

Commit

Permalink
fix: Disable active_timer When registry_ttl_sec is 0
Browse files Browse the repository at this point in the history
Signed-off-by: Jiwon Park <[email protected]>
  • Loading branch information
phil-park committed Sep 9, 2024
1 parent 7ecc615 commit 5b33eec
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions sdk/python/feast/feature_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class MaterializeIncrementalRequest(BaseModel):


def get_app(
store: "feast.FeatureStore",
registry_ttl_sec: int = DEFAULT_FEATURE_SERVER_REGISTRY_TTL,
store: "feast.FeatureStore",
registry_ttl_sec: int = DEFAULT_FEATURE_SERVER_REGISTRY_TTL,
):
proto_json.patch()
# Asynchronously refresh registry, notifying shutdown and canceling the active timer if the app is shutting down
Expand All @@ -90,9 +90,11 @@ def async_refresh():
registry_proto = store.registry.proto()
if shutting_down:
return
nonlocal active_timer
active_timer = threading.Timer(registry_ttl_sec, async_refresh)
active_timer.start()

if registry_ttl_sec:
nonlocal active_timer
active_timer = threading.Timer(registry_ttl_sec, async_refresh)
active_timer.start()

@asynccontextmanager
async def lifespan(app: FastAPI):
Expand Down Expand Up @@ -181,9 +183,9 @@ def push(body=Depends(get_body)):
fv
for fv in all_fvs
if (
fv.stream_source is not None
and isinstance(fv.stream_source, PushSource)
and fv.stream_source.name == request.push_source_name
fv.stream_source is not None
and isinstance(fv.stream_source, PushSource)
and fv.stream_source.name == request.push_source_name
)
}

Expand Down Expand Up @@ -269,6 +271,7 @@ async def rest_exception_handler(request: Request, exc: Exception):
if sys.platform != "win32":
import gunicorn.app.base


class FeastServeApplication(gunicorn.app.base.BaseApplication):
def __init__(self, store: "feast.FeatureStore", **options):
self._app = get_app(
Expand Down Expand Up @@ -306,14 +309,14 @@ def monitor_resources(self, interval: int = 5):


def start_server(
store: "feast.FeatureStore",
host: str,
port: int,
no_access_log: bool,
workers: int,
keep_alive_timeout: int,
registry_ttl_sec: int,
metrics: bool,
store: "feast.FeatureStore",
host: str,
port: int,
no_access_log: bool,
workers: int,
keep_alive_timeout: int,
registry_ttl_sec: int,
metrics: bool,
):
if metrics:
logger.info("Starting Prometheus Server")
Expand Down

0 comments on commit 5b33eec

Please sign in to comment.