Describe the bug
I integrated tortoise-orm in FastAPI, but it reported an error when started in debug mode
This is my project structure
project
| - server.py
| - dao
| - models.py
this is my code:
`
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
app startup
async with RegisterTortoise(
app,
db_url=setting.dbUrl,
modules={"models": ["dao.models"]},
generate_schemas=True,
add_exception_handlers=True,
) as session:
# db connected
yield
# app teardown
# db connections closed
app = FastAPI(lifespan=lifespan)
if name == "main":
uvicorn.run(app, host="0.0.0.0", port=8080)
`
this is error detail:
Exception in callback <Task pending name='Task-1' coro=<Server.serve() running at /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/uvicorn/server.py:71> cb=[run_until_complete..done_cb()]>\nhandle: <Handle <Task pending name='Task-1' coro=<Server.serve() running at /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/uvicorn/server.py:71> cb=[run_until_complete..done_cb()]>>\nTraceback (most recent call last):\n File \"uvloop/cbhandles.pyx\", line 61, in uvloop.loop.Handle._run\nTypeError: 'Task' object is not callable
Describe the bug I integrated tortoise-orm in FastAPI, but it reported an error when started in debug mode
This is my project structure
this is my code: ` @asynccontextmanager async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
app startup
app = FastAPI(lifespan=lifespan)
if name == "main": uvicorn.run(app, host="0.0.0.0", port=8080) ` this is error detail: Exception in callback <Task pending name='Task-1' coro=<Server.serve() running at /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/uvicorn/server.py:71> cb=[run_until_complete..done_cb()]>\nhandle: <Handle <Task pending name='Task-1' coro=<Server.serve() running at /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/uvicorn/server.py:71> cb=[run_until_complete..done_cb()]>>\nTraceback (most recent call last):\n File \"uvloop/cbhandles.pyx\", line 61, in uvloop.loop.Handle._run\nTypeError: 'Task' object is not callable