Skip to content

Commit

Permalink
Update client.py (#1697)
Browse files Browse the repository at this point in the history
psycopg_pool updated and generated a RuntimeWarning. 
"RuntimeWarning: opening the async pool AsyncConnectionPool in the constructor is deprecated and will not be supported anymore in a future release. Please use `await pool.open()`, or use the pool as context manager using: `async with AsyncConnectionPool(...) as pool: `..."
update "create_pool" function, call "await pool.open()" explicitly.
  • Loading branch information
zxj17815 authored Aug 17, 2024
1 parent 5ca0c5f commit 1ca1cad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tortoise/backends/psycopg/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ async def create_connection(self, with_db: bool) -> None:
)

async def create_pool(self, **kwargs) -> AsyncConnectionPool:
return AsyncConnectionPool(**kwargs)
pool = AsyncConnectionPool(open=False, **kwargs)
await pool.open()
return pool

async def db_delete(self) -> None:
try:
Expand Down

0 comments on commit 1ca1cad

Please sign in to comment.