Skip to content

Commit 7685960

Browse files
committed
postgres: use wait_for in disconnect
This is recommended by asyncpg [1]. 1: https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L655-L656
1 parent 88b381a commit 7685960

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

databases/backends/postgres.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import logging
23
import typing
34
from collections.abc import Mapping
@@ -66,7 +67,7 @@ async def connect(self) -> None:
6667

6768
async def disconnect(self) -> None:
6869
assert self._pool is not None, "DatabaseBackend is not running"
69-
await self._pool.close()
70+
await asyncio.wait_for(self._pool.close(), timeout=30)
7071
self._pool = None
7172

7273
def connection(self) -> "PostgresConnection":

0 commit comments

Comments
 (0)