mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 11:18:27 +08:00
tools: Wrap Task _do() calls in a generic exception handler
Signed-off-by: Charles Baynham <charles.baynham@npl.co.uk>
This commit is contained in:
parent
e50a6d5aaf
commit
0b1fb255a9
@ -240,7 +240,16 @@ async def asyncio_wait_or_cancel(fs, **kwargs):
|
||||
|
||||
class TaskObject:
|
||||
def start(self):
|
||||
self.task = asyncio.ensure_future(self._do())
|
||||
async def log_exceptions(awaitable):
|
||||
try:
|
||||
return await awaitable()
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception:
|
||||
logger.error("Unhandled exception in TaskObject task body", exc_info=True)
|
||||
raise
|
||||
|
||||
self.task = asyncio.ensure_future(log_exceptions(self._do))
|
||||
|
||||
async def stop(self):
|
||||
self.task.cancel()
|
||||
|
Loading…
Reference in New Issue
Block a user