Questions tagged [lifespan]

4 questions
2
votes
2 answers

Django can only handle ASGI/HTTP connections, not lifespan. in uvicorn

The problem: ValueError generic ASGI request Unhandled Django can only handle ASGI/HTTP connections, not lifespan. I'm using: Django==3.2.6 gunicorn==20.1.0 uvicorn==0.20.0 docker CMD: gunicorn --bind 0.0.0.0:9999 --workers 1 --threads 8…
C.K.
  • 4,348
  • 29
  • 43
0
votes
0 answers

lifepsan not running while running the fastapi, only the old version of lifespan is working

@asynccontextmanager async def lifespan(app: FastAPI): print("startup") await news_db_client.connect() yield await news_db_client.disconnect() app = FastAPI(lifespan=lifespan) this part of code doesnt get executed, but when tyring…
0
votes
2 answers

fastapi lifespan closing session raises AttributeError: 'SQLAlchemyUserDatabase' object has no attribute 'close'

I am using fastapi (0.95.0), fastapi-users (10.4.2), fastapi-users-db-sqlalchemy (5.0.0) and SQLAlchemy (2.0.10) in my application. This is a simplified snippet of my code: engine = create_async_engine(SQLALCHEMY_DATABASE_URL) async_session_maker =…
Homunculus Reticulli
  • 65,167
  • 81
  • 216
  • 341
0
votes
1 answer

FastAPI: AttributeError: 'myFastAPI' object has no attribute 'router'

I have created a child class and inherited FastAPI class. I want to define a function lifespan inside it. To implement lifespan I need to create constructor inside myFastAPI class. Below is sample code. class myFastAPI(FastAPI): def…
LOrD_ARaGOrN
  • 3,884
  • 3
  • 27
  • 49