tortoise / tortoise/tortoise-orm
Create a background task use asyncio.create_task, DB connection issue occurs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Describe the bug
Use Sanic , when received a request , add a background task to update DB by asyncio.create_task
this error occurs:
asyncpg.exceptions._base.InterfaceError: cannot call Connection.execute(): connection has been released back to the pool
the full trace is :
To Reproduce
DB: postgresql 12
Sanic: 22.9.0
tortoise: 0.19.2
Additional context
I also report this to Sanic, the feedback of creator of Sanic :
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Start by reproducing the asyncio.create_task failure with PostgreSQL 12, Sanic 22.9.0, and Tortoise 0.19.2, then trace the background task's database connection lifetime around the reported asyncpg InterfaceError. Done means the connection-release behavior is understood and a regression test or clearly scoped fix is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100