-
Notifications
You must be signed in to change notification settings - Fork 262
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
Database connection hanging after a test with transaction #531
Comments
Possibly related, not entirely sure: #546 |
Not related/fixed by #546, but I ran into something like this while working on that PR. Based on your example I think this is caused by your code in You should not await a transaction's creation when using the low-level transaction management logic. Try this: # file: router.py
@router.get("/test")
async def get_test():
- transaction = await main.database.transaction()
+ transaction = main.database.transaction()
try:
await transaction.start()
except UniqueViolationError:
await transaction.rollback()
raise HTTPException(status_code=400, detail="error")
else:
await transaction.commit()
return 200 |
Thanks for the time you took to respond to this issue. Priorities have shift in my projet, I won't be able to test this before a few weeks. I'll make sure to update this issue when I'm back at it. |
Hi, I am developing an API using FastAPI and Databases. I recently updated most of the projects libraries, and I'm encountering some issue with my tests. I used to use pytest-asyncio, but since the fastapi update I am now using anyio.
I was not too sure if this was the correct repository to post my issue.
When I have a transaction the database connection seems to hang at the end. I have provided simples snippets of code to reproduce the issue. As well as the hanging piece of code located in the asyncpg library. There are no error message, and I have to quit the process manually to stop it.
Here are the libraries' versions:
Fastapi main
conftest.py
test.py
router.py
The hanging happens in
asyncpg.pool.py
inclose()
I hope this is enough information.
Thank you for your times
The text was updated successfully, but these errors were encountered: