tortoise / tortoise/tortoise-orm
InterfaceError: pool is closing
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
I am using FastAPI with tortoise orm.
I am trying to handle around 4 to 5 data retrievals and update the data.
Every time I update, I am locking the database row using select_for_update and update the data.
My whole process runs in the background with celery.
I get the below error.
Has anyone faced a similar issue and found a solution to this?
File "/usr/local/lib/python3.10/site-packages/tortoise/queryset.py", line 1006, in _execute
instance_list = await self._db.executor_class(
File "/usr/local/lib/python3.10/site-packages/tortoise/backends/base/executor.py", line 130, in execute_select
_, raw_results = await self.db.execute_query(query.get_sql())
File "/usr/local/lib/python3.10/site-packages/tortoise/backends/base_postgres/client.py", line 24, in _translate_exceptions
return await self._translate_exceptions(func, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/tortoise/backends/asyncpg/client.py", line 79, in _translate_exceptions
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/tortoise/backends/asyncpg/client.py", line 126, in execute_query
async with self.acquire_connection() as connection:
File "/usr/local/lib/python3.10/site-packages/tortoise/backends/base/client.py", line 328, in __aenter__
self.connection = await self.pool.acquire()
File "/usr/local/lib/python3.10/site-packages/asyncpg/pool.py", line 822, in _acquire
raise exceptions.InterfaceError('pool is closing')
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
Start with the traceback locations in tortoise/queryset.py, tortoise/backends/base/executor.py, tortoise/backends/base_postgres/client.py, and tortoise/backends/asyncpg/client.py, then review how the Celery background process initializes and closes the pool. Reproduce the select_for_update and update workflow and identify why acquisition occurs after pool shutdown; done means the workflow completes without InterfaceError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, postgresql, python
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100