From: Sarah Hoffmann Date: Thu, 24 Aug 2023 14:29:21 +0000 (+0200) Subject: use backwards-compatible asyncio timeout implementation X-Git-Tag: v4.3.0~15^2~1 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/161d17d85b99af48a765f4536b2a7178a5fc7d96?ds=inline;hp=-c use backwards-compatible asyncio timeout implementation --- 161d17d85b99af48a765f4536b2a7178a5fc7d96 diff --git a/nominatim/api/connection.py b/nominatim/api/connection.py index f124b189..405213e9 100644 --- a/nominatim/api/connection.py +++ b/nominatim/api/connection.py @@ -51,8 +51,7 @@ class SearchConnection: """ Execute a 'scalar()' query on the connection. """ log().sql(self.connection, sql, params) - async with asyncio.timeout(self.query_timeout): - return await self.connection.scalar(sql, params) + return await asyncio.wait_for(self.connection.scalar(sql, params), self.query_timeout) async def execute(self, sql: 'sa.Executable', @@ -61,8 +60,7 @@ class SearchConnection: """ Execute a 'execute()' query on the connection. """ log().sql(self.connection, sql, params) - async with asyncio.timeout(self.query_timeout): - return await self.connection.execute(sql, params) + return await asyncio.wait_for(self.connection.execute(sql, params), self.query_timeout) async def get_property(self, name: str, cached: bool = True) -> str: