This commit is contained in:
Jack Robison 2022-02-01 13:43:01 -05:00
parent 46ce175481
commit d7e50b269f
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 5 additions and 4 deletions

View file

@ -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()

View file

@ -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)