Merge pull request #2761 from lbryio/catch-notification-timeout

catch TimeoutError when attempting to send notifications
This commit is contained in:
Jack Robison 2020-02-03 19:03:07 -05:00 committed by GitHub
commit dc393f4b77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -879,7 +879,12 @@ class LBRYElectrumX(SessionBase):
""" """
if height_changed and self.subscribe_headers: if height_changed and self.subscribe_headers:
args = (await self.subscribe_headers_result(), ) args = (await self.subscribe_headers_result(), )
await self.send_notification('blockchain.headers.subscribe', args) try:
await self.send_notification('blockchain.headers.subscribe', args)
except asyncio.TimeoutError:
self.logger.info("timeout sending headers notification to %s", self.peer_address_str(for_log=True))
self.abort()
return
touched = touched.intersection(self.hashX_subs) touched = touched.intersection(self.hashX_subs)
if touched or (height_changed and self.mempool_statuses): if touched or (height_changed and self.mempool_statuses):
@ -907,7 +912,13 @@ class LBRYElectrumX(SessionBase):
method = 'blockchain.scripthash.subscribe' method = 'blockchain.scripthash.subscribe'
else: else:
method = 'blockchain.address.subscribe' method = 'blockchain.address.subscribe'
await self.send_notification(method, (alias, status))
try:
await self.send_notification(method, (alias, status))
except asyncio.TimeoutError:
self.logger.info("timeout sending address notification to %s", self.peer_address_str(for_log=True))
self.abort()
return
if changed: if changed:
es = '' if len(changed) == 1 else 'es' es = '' if len(changed) == 1 else 'es'