X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/bc75e5626ec59523707b842022ecf0bdc159cf06..1f0796778754d8df0dfab9dd01302e26a397f064:/src/nominatim_db/db/query_pool.py diff --git a/src/nominatim_db/db/query_pool.py b/src/nominatim_db/db/query_pool.py index 2828937f..08a92048 100644 --- a/src/nominatim_db/db/query_pool.py +++ b/src/nominatim_db/db/query_pool.py @@ -18,6 +18,7 @@ LOG = logging.getLogger() QueueItem = Optional[Tuple[psycopg.abc.Query, Any]] + class QueryPool: """ Pool to run SQL queries in parallel asynchronous execution. @@ -32,7 +33,6 @@ class QueryPool: self.pool = [asyncio.create_task(self._worker_loop(dsn, **conn_args)) for _ in range(pool_size)] - async def put_query(self, query: psycopg.abc.Query, params: Any) -> None: """ Schedule a query for execution. """ @@ -41,7 +41,6 @@ class QueryPool: self.wait_time += time.time() - tstart await asyncio.sleep(0) - async def finish(self) -> None: """ Wait for all queries to finish and close the pool. """ @@ -57,7 +56,6 @@ class QueryPool: if excp is not None: raise excp - async def _worker_loop(self, dsn: str, **conn_args: Any) -> None: conn_args['autocommit'] = True aconn = await psycopg.AsyncConnection.connect(dsn, **conn_args) @@ -78,10 +76,8 @@ class QueryPool: str(item[0]), str(item[1])) # item is still valid here, causing a retry - async def __aenter__(self) -> 'QueryPool': return self - async def __aexit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: await self.finish()