From d7e50b269f22c75462fa95589aac8dc42ed6ba4e Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 1 Feb 2022 13:43:01 -0500 Subject: [PATCH] fix test --- lbry/wallet/server/chain_reader.py | 2 +- lbry/wallet/server/db/elasticsearch/search.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lbry/wallet/server/chain_reader.py b/lbry/wallet/server/chain_reader.py index 9c7bcab2e..7f1f8b48f 100644 --- a/lbry/wallet/server/chain_reader.py +++ b/lbry/wallet/server/chain_reader.py @@ -218,7 +218,7 @@ class BlockchainReaderServer(BlockchainReader): t = self.cancellable_tasks.pop() if not t.done(): t.cancel() - self.session_manager.search_index.stop() + await self.session_manager.search_index.stop() self.db.close() if self.prometheus_server: await self.prometheus_server.stop() diff --git a/lbry/wallet/server/db/elasticsearch/search.py b/lbry/wallet/server/db/elasticsearch/search.py index 3111155a9..859ee056c 100644 --- a/lbry/wallet/server/db/elasticsearch/search.py +++ b/lbry/wallet/server/db/elasticsearch/search.py @@ -92,10 +92,11 @@ class SearchIndex: await self.sync_client.indices.refresh(self.index) return acked - def stop(self): - clients = [self.sync_client, self.search_client] + async def stop(self): + clients = [c for c in (self.sync_client, self.search_client) if c is not None] self.sync_client, self.search_client = None, None - return asyncio.ensure_future(asyncio.gather(*(client.close() for client in clients))) + if clients: + await asyncio.gather(*(client.close() for client in clients)) def delete_index(self): return self.sync_client.indices.delete(self.index, ignore_unavailable=True)