Browse Source

Have task coros handle cancelled exceptions

master
Neil Booth 8 years ago
parent
commit
db187540d5
  1. 2
      server/block_processor.py
  2. 6
      server/irc.py
  3. 4
      server/protocol.py

2
server/block_processor.py

@ -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.

6
server/irc.py

@ -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 "{}"'

4
server/protocol.py

@ -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))

Loading…
Cancel
Save