Have task coros handle cancelled exceptions

This commit is contained in:
Neil Booth 2016-11-15 08:12:52 +09:00
parent a2280bbc93
commit db187540d5
3 changed files with 11 additions and 1 deletions

View File

@ -91,6 +91,8 @@ class Prefetcher(LoggedClass):
await asyncio.sleep(0)
except DaemonError as e:
self.logger.info('ignoring daemon error: {}'.format(e))
except asyncio.CancelledError:
break
async def _caught_up(self):
'''Poll for new blocks and mempool state.

View File

@ -51,6 +51,12 @@ class IRC(LoggedClass):
self.peers = {}
async def start(self):
try:
await self.join()
except asyncio.CancelledError:
pass
async def join(self):
import irc.client as irc_client
self.logger.info('joining IRC with nick "{}" and real name "{}"'

View File

@ -235,8 +235,10 @@ class Session(JSONRPC):
secs = time.time() - start
if secs > 1:
self.logger.warning('slow request for {} took {:.1f}s: {}'
.format(session.peername(), secs,
.format(self.peername(), secs,
request))
except asyncio.CancelledError:
break
except Exception:
# Getting here should probably be considered a bug and fixed
self.logger.error('error handling request {}'.format(request))