Shield the taking of the lock, otherwise it is lost
This commit is contained in:
parent
e2d3f655fb
commit
028374ede4
@ -190,8 +190,15 @@ class BlockProcessor(electrumx.server.db.DB):
|
|||||||
self.state_lock = asyncio.Lock()
|
self.state_lock = asyncio.Lock()
|
||||||
|
|
||||||
async def run_in_thread_shielded(self, func, *args):
|
async def run_in_thread_shielded(self, func, *args):
|
||||||
async with self.state_lock:
|
# Run in a thread to prevent blocking. Shielded so that
|
||||||
return await asyncio.shield(run_in_thread(func, *args))
|
# cancellations from shutdown don't lose work - when the task
|
||||||
|
# completes the data will be flushed and then we shut down.
|
||||||
|
# Take the state lock to be certain in-memory state is
|
||||||
|
# consistent and not being updated elsewhere.
|
||||||
|
async def run_in_thread_locked():
|
||||||
|
async with self.state_lock:
|
||||||
|
return await run_in_thread(func, *args)
|
||||||
|
return await asyncio.shield(run_in_thread_locked())
|
||||||
|
|
||||||
async def check_and_advance_blocks(self, raw_blocks):
|
async def check_and_advance_blocks(self, raw_blocks):
|
||||||
'''Process the list of raw blocks passed. Detects and handles
|
'''Process the list of raw blocks passed. Detects and handles
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user