From 20a5aecfca42c8917934fdc4435139a36c437b3f Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 9 Mar 2021 02:17:19 -0300 Subject: [PATCH] fix lib exception to asyncio TimeoutError --- lbry/wallet/server/db/elastic_search.py | 3 +++ lbry/wallet/server/session.py | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lbry/wallet/server/db/elastic_search.py b/lbry/wallet/server/db/elastic_search.py index d25872d97..0977559a2 100644 --- a/lbry/wallet/server/db/elastic_search.py +++ b/lbry/wallet/server/db/elastic_search.py @@ -8,6 +8,7 @@ from operator import itemgetter from typing import Optional, List, Iterable from elasticsearch import AsyncElasticsearch, NotFoundError, ConnectionError +from elasticsearch.exceptions import ConnectionTimeout from elasticsearch.helpers import async_streaming_bulk from lbry.crypto.base58 import Base58 @@ -228,6 +229,8 @@ class SearchIndex: expand_query(**kwargs), index=self.index, track_total_hits=200 ) cache_item.result = zlib.compress(json.dumps(result).encode(), 1) + except ConnectionTimeout: + raise TimeoutError() except NotFoundError: # index has no docs, fixme: log something return [], 0, 0 diff --git a/lbry/wallet/server/session.py b/lbry/wallet/server/session.py index daf8aa9f3..ef9f62c7f 100644 --- a/lbry/wallet/server/session.py +++ b/lbry/wallet/server/session.py @@ -1009,9 +1009,7 @@ class LBRYElectrumX(SessionBase): try: self.session_mgr.pending_query_metric.inc() return await self.db.search_index.session_query(query_name, kwargs) - except (TimeoutError, asyncio.TimeoutError) as error: - metrics = self.get_metrics_or_placeholder_for_api(query_name) - metrics.query_interrupt(start, error.metrics) + except (TimeoutError, asyncio.TimeoutError): self.session_mgr.interrupt_count_metric.inc() raise RPCError(JSONRPC.QUERY_TIMEOUT, 'query timed out') finally: