catch exceptions from Worker.run
This commit is contained in:
parent
8b8f2d1d8a
commit
9ee53041b6
|
@ -259,7 +259,7 @@ class Dispatcher:
|
|||
func = mod.get_version
|
||||
ctx.run(worker.initialize, func)
|
||||
|
||||
ret.append(ctx.run(worker.run))
|
||||
ret.append(ctx.run(worker._run_maynot_raise))
|
||||
|
||||
return ret
|
||||
|
||||
|
|
|
@ -146,6 +146,13 @@ class BaseWorker:
|
|||
'''Run the `tasks`. Subclasses should implement this method.'''
|
||||
raise NotImplementedError
|
||||
|
||||
async def _run_maynot_raise(self) -> None:
|
||||
try:
|
||||
await self.run()
|
||||
except Exception:
|
||||
# don't let an exception tear down the whole process
|
||||
logger.exception('exception raised by Worker.run')
|
||||
|
||||
class AsyncCache:
|
||||
'''A cache for use with async functions.'''
|
||||
cache: Dict[Hashable, Any]
|
||||
|
|
Loading…
Reference in New Issue