]> git.openstreetmap.org Git - nominatim.git/commitdiff
use backwards-compatible asyncio timeout implementation
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 24 Aug 2023 14:29:21 +0000 (16:29 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 25 Aug 2023 06:50:03 +0000 (08:50 +0200)
nominatim/api/connection.py

index f124b1894ca96d9b47c99bb04767c281d5eb5ace..405213e97659d32fb9ff9d56c2478219690af6a4 100644 (file)
@@ -51,8 +51,7 @@ class SearchConnection:
         """ Execute a 'scalar()' query on the connection.
         """
         log().sql(self.connection, sql, params)
         """ 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',
 
 
     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)
         """ 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:
 
 
     async def get_property(self, name: str, cached: bool = True) -> str: