diff --git a/server/block_processor.py b/server/block_processor.py index 2b2840d..ea4265e 100644 --- a/server/block_processor.py +++ b/server/block_processor.py @@ -64,7 +64,7 @@ class Prefetcher(LoggedClass): Used in blockchain reorganisations. This coroutine can be called asynchronously to the _prefetch coroutine so we must synchronize with a semaphore.''' - with await self.semaphore: + async with self.semaphore: self.fetched_height = self.bp.height self.refill_event.set() @@ -85,7 +85,7 @@ class Prefetcher(LoggedClass): ''' daemon = self.bp.daemon daemon_height = await daemon.height(self.bp.caught_up_event.is_set()) - with await self.semaphore: + async with self.semaphore: while self.cache_size < self.min_cache_size: # Try and catch up all blocks but limit to room in cache. # Constrain fetch count to between 0 and 500 regardless; diff --git a/server/db.py b/server/db.py index 46aef3f..9b1cc6b 100644 --- a/server/db.py +++ b/server/db.py @@ -662,7 +662,7 @@ class DB(util.LoggedClass): while self.comp_cursor != -1: if self.semaphore.locked: self.log_info('compact_history: waiting on semaphore...') - with await self.semaphore: + async with self.semaphore: await loop.run_in_executor(None, self._compact_history, limit) def cancel_history_compaction(self):