Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH]: FastAPI Shutdown hook #1665

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
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
5 changes: 5 additions & 0 deletions chromadb/server/fastapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ def __init__(self, settings: Settings):
allow_methods=["*"],
)

self._app.on_event("shutdown")(self.shutdown)

if settings.chroma_server_authz_provider:
self._app.add_middleware(
FastAPIChromaAuthzMiddlewareWrapper,
Expand Down Expand Up @@ -280,6 +282,9 @@ def __init__(self, settings: Settings):
use_route_names_as_operation_ids(self._app)
instrument_fastapi(self._app)

def shutdown(self) -> None:
self._system.stop()

def app(self) -> fastapi.FastAPI:
return self._app

Expand Down
Loading