Browse Source

daemon.py: work around aiohttp bug

Also log unexpected exceptions in the prefetcher
patch-2
Neil Booth 6 years ago
parent
commit
d90d76cbdd
  1. 3
      electrumx/server/block_processor.py
  2. 8
      electrumx/server/daemon.py

3
electrumx/server/block_processor.py

@ -55,6 +55,9 @@ class Prefetcher(object):
await asyncio.sleep(self.polling_delay)
except DaemonError as e:
self.logger.info(f'ignoring daemon error: {e}')
except Exception:
self.logger.exception(f'unexpected exception')
raise
def get_prefetched_blocks(self):
'''Called by block processor when it is processing queued blocks.'''

8
electrumx/server/daemon.py

@ -150,6 +150,14 @@ class Daemon(object):
except WorkQueueFullError:
log_error('work queue full.')
on_good_message = 'running normally'
except CancelledError as e:
# aiohttp bug - it raises a CancelledError (!!) if the transport is
# closing; presumably bitcoind is busy and closes the connection early.
# See https://github.com/aio-libs/aiohttp/issues/2499
if 'closing transport' not in str(e):
raise
log_error('disconnected.')
on_good_message = 'connection restored'
await asyncio.sleep(retry)
retry = max(min(self.max_retry, retry * 2), self.init_retry)

Loading…
Cancel
Save