Closed
Description
When you connect to a Weaviate instance in the Gunicorn on_startup
server hook and close the connection, afterwards I'm unable to connect again inside the uvicorn workers (deployment setup for FastAPI application).
gunicorn.conf.py
import weaviate
def on_starting(server):
client = weaviate.connect_to_custom(
http_host=localhost,
http_port=8080,
http_secure=False,
grpc_host=localhost,
grpc_port=50051,
grpc_secure=False,
)
client.close()
app.py (FastAPI)
from fastapi import FastAPI
from contextlib import asynccontextmanager
import weaviate
@asynccontextmanager
async def setup_databases(app: FastAPI):
client = weaviate.connect_to_custom(
http_host=localhost,
http_port=8080,
http_secure=False,
grpc_host=localhost,
grpc_port=50051,
grpc_secure=False,
)
yield
weaviate_client.close()
app = FastAPI(lifespan=setup_databases)
Run with gunicorn -b 0.0.0.0:8000 -c gunicorn.conf.py app:app
.
Inside the on_starting hook, i can close and connect as often as I want, same for inside the FastAPI application. As soon as i close the connection to Weaviate once in the on_starting hook, connect_to_custom hangs up inside the application. This first happened with Weaviate python client version 4.7.0 (4.7.1 & 4.8.0 also don't work), for versions <= 4.6.7 everything works fine.
Weaviate Server Version: 1.26.1