From ae337807f554759c08e25000f836ec4b32a6d57b Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 10 Mar 2021 13:05:17 -0300 Subject: [PATCH] get merkles outside thread cooperatively --- lbry/wallet/server/session.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lbry/wallet/server/session.py b/lbry/wallet/server/session.py index c00da0189..fbe721d02 100644 --- a/lbry/wallet/server/session.py +++ b/lbry/wallet/server/session.py @@ -1552,15 +1552,14 @@ class LBRYElectrumX(SessionBase): else: batch_result[tx_hash] = [raw_tx, {'block_height': -1}] - def threaded_get_merkle(): + if needed_merkles: for tx_hash, (raw_tx, block_txs, pos, block_height) in needed_merkles.items(): batch_result[tx_hash] = raw_tx, { 'merkle': self._get_merkle_branch(block_txs, pos), 'pos': pos, 'block_height': block_height } - if needed_merkles: - await asyncio.get_running_loop().run_in_executor(self.db.executor, threaded_get_merkle) + await asyncio.sleep(0) # heavy call, give other tasks a chance self.session_mgr.tx_replied_count_metric.inc(len(tx_hashes)) return batch_result