From 8a2517aa36b5d9155e0a57ecddab86ab731fe449 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 5 Apr 2022 15:40:51 -0400 Subject: [PATCH] run in thread --- scribe/db/db.py | 8 ++++++++ scribe/hub/session.py | 7 +------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scribe/db/db.py b/scribe/db/db.py index ab22ae7..bb9ea00 100644 --- a/scribe/db/db.py +++ b/scribe/db/db.py @@ -850,6 +850,14 @@ class HubDB: self.prefix_db.close() self.prefix_db = None + def get_hashX_status(self, hashX: bytes): + mempool_status = self.prefix_db.hashX_mempool_status.get(hashX) + if mempool_status: + return mempool_status.status.hex() + status = self.prefix_db.hashX_status.get(hashX) + if status: + return status.status.hex() + def get_tx_hash(self, tx_num: int) -> bytes: if self._cache_all_tx_hashes: return self.total_transactions[tx_num] diff --git a/scribe/hub/session.py b/scribe/hub/session.py index e212023..ed246a1 100644 --- a/scribe/hub/session.py +++ b/scribe/hub/session.py @@ -1101,12 +1101,7 @@ class LBRYElectrumX(asyncio.Protocol): return len(self.hashX_subs) async def get_hashX_status(self, hashX: bytes): - mempool_status = self.db.prefix_db.hashX_mempool_status.get(hashX) - if mempool_status: - return mempool_status.status.hex() - status = self.db.prefix_db.hashX_status.get(hashX) - if status: - return status.status.hex() + return await self.loop.run_in_executor(self.db._executor, self.db.get_hashX_status, hashX) async def send_history_notifications(self, *hashXes: typing.Iterable[bytes]): notifications = []