taskgroups: don't log CancelledError
This commit is contained in:
@@ -312,14 +312,17 @@ class Daemon(Logger):
|
|||||||
async def _run(self, jobs: Iterable = None):
|
async def _run(self, jobs: Iterable = None):
|
||||||
if jobs is None:
|
if jobs is None:
|
||||||
jobs = []
|
jobs = []
|
||||||
|
self.logger.info("starting taskgroup.")
|
||||||
try:
|
try:
|
||||||
async with self.taskgroup as group:
|
async with self.taskgroup as group:
|
||||||
[await group.spawn(job) for job in jobs]
|
[await group.spawn(job) for job in jobs]
|
||||||
await group.spawn(asyncio.Event().wait) # run forever (until cancel)
|
await group.spawn(asyncio.Event().wait) # run forever (until cancel)
|
||||||
except BaseException as e:
|
except asyncio.CancelledError:
|
||||||
self.logger.exception('daemon.taskgroup died.')
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.exception("taskgroup died.")
|
||||||
finally:
|
finally:
|
||||||
self.logger.info("stopping daemon.taskgroup")
|
self.logger.info("taskgroup stopped.")
|
||||||
|
|
||||||
async def authenticate(self, headers):
|
async def authenticate(self, headers):
|
||||||
if self.rpc_password == '':
|
if self.rpc_password == '':
|
||||||
|
|||||||
@@ -161,11 +161,16 @@ class LNWorker(Logger):
|
|||||||
|
|
||||||
@ignore_exceptions # don't kill outer taskgroup
|
@ignore_exceptions # don't kill outer taskgroup
|
||||||
async def main_loop(self):
|
async def main_loop(self):
|
||||||
|
self.logger.info("starting taskgroup.")
|
||||||
try:
|
try:
|
||||||
async with self.taskgroup as group:
|
async with self.taskgroup as group:
|
||||||
await group.spawn(self._maintain_connectivity())
|
await group.spawn(self._maintain_connectivity())
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.exception("taskgroup died.")
|
self.logger.exception("taskgroup died.")
|
||||||
|
finally:
|
||||||
|
self.logger.info("taskgroup stopped.")
|
||||||
|
|
||||||
async def _maintain_connectivity(self):
|
async def _maintain_connectivity(self):
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
@@ -1131,6 +1131,7 @@ class Network(Logger):
|
|||||||
self._start_interface(self.default_server)
|
self._start_interface(self.default_server)
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
self.logger.info("starting taskgroup.")
|
||||||
try:
|
try:
|
||||||
await self._init_headers_file()
|
await self._init_headers_file()
|
||||||
# note: if a task finishes with CancelledError, that
|
# note: if a task finishes with CancelledError, that
|
||||||
@@ -1138,9 +1139,12 @@ class Network(Logger):
|
|||||||
async with taskgroup as group:
|
async with taskgroup as group:
|
||||||
await group.spawn(self._maintain_sessions())
|
await group.spawn(self._maintain_sessions())
|
||||||
[await group.spawn(job) for job in self._jobs]
|
[await group.spawn(job) for job in self._jobs]
|
||||||
except BaseException as e:
|
except asyncio.CancelledError:
|
||||||
self.logger.exception('taskgroup died.')
|
raise
|
||||||
raise e
|
except Exception as e:
|
||||||
|
self.logger.exception("taskgroup died.")
|
||||||
|
finally:
|
||||||
|
self.logger.info("taskgroup stopped.")
|
||||||
asyncio.run_coroutine_threadsafe(main(), self.asyncio_loop)
|
asyncio.run_coroutine_threadsafe(main(), self.asyncio_loop)
|
||||||
|
|
||||||
self.trigger_callback('network_updated')
|
self.trigger_callback('network_updated')
|
||||||
|
|||||||
Reference in New Issue
Block a user