'async_generator is not a callable object' dependency issue
See original GitHub issueThe get_db dependency causes a weird
TypeError: <async_generator object get_db at 0x7ff6d9d9aa60> is not a callable object
issue on my project.
Here’s my code:
db.py
from typing import Generator
from .db.session import SessionLocal
async def get_db() -> Generator:
try:
db = SessionLocal()
yield db
finally:
await db.close()
session.py
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from .core.config import settings
engine = create_async_engine(
settings.SQLALCHEMY_DATABASE_URI,
pool_pre_ping=True
)
SessionLocal = AsyncSession(
autocommit=False,
autoflush=False,
bind=engine
)
_Originally posted by @joweenflores in https://github.com/tiangolo/fastapi/pull/2331#issuecomment-821941735_
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
python - 'async_generator is not a callable object' FastAPI ...
I am trying to create a FastAPI and async sqlalchemy. The get_db dependency causes a weird TypeError: < ...
Read more >Strange behavior with await in a generator expression
Perhaps we can make the "TypeError: 'async_generator' object is not iterable" error message a bit clearer. Any ideas to improve it are welcome....
Read more >TypeError: 'generator' object is not callable in Python
The Python TypeError: 'generator' object is not callable occurs when we try to call a generator object as if it were a function....
Read more >python/typing - Gitter
With async def agen(): yield , the type of agen() is AsyncGenerator. A Coroutine is the object returned by calling an async function...
Read more >TypeError on Rasa 3.0 'NoneType' object is not callable
Please update these packages and dependencies issues and even pip version also give issue. python-engineio==4.3.0 python-socketio==5.5.0 rasa== ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
it worked! wow. thanks a lot 💯 I’m such a dumbass
you shouldn’t call get_db. Try just
Depends(get_db)