From 76859604c6f09483133d414851f5ca3b9296c34d Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 7 May 2019 08:17:51 +0200 Subject: [PATCH] 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 --- databases/backends/postgres.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/databases/backends/postgres.py b/databases/backends/postgres.py index 511e9579..f6516040 100644 --- a/databases/backends/postgres.py +++ b/databases/backends/postgres.py @@ -1,3 +1,4 @@ +import asyncio import logging import typing from collections.abc import Mapping @@ -66,7 +67,7 @@ async def connect(self) -> None: async def disconnect(self) -> None: assert self._pool is not None, "DatabaseBackend is not running" - await self._pool.close() + await asyncio.wait_for(self._pool.close(), timeout=30) self._pool = None def connection(self) -> "PostgresConnection":