Catches errors in _started_service() function which previously passed by uncaught
@@ -194,7 +194,16 @@ class ServiceContainer(object):
logging.getLogger("exception").exception("Uncaught exception: {}".format(str(e)))
if started_futures and any(started_futures):
- await asyncio.wait([asyncio.ensure_future(func()) for func in started_futures if func])
+ started_futures_result = await asyncio.wait([asyncio.ensure_future(func()) for func in started_futures if func])
+ exception = [v.exception() for v in [value for value in started_futures_result if value][0] if v.exception()]
+ if exception:
+ self.logger.warning("Failed to start service (exception raised in '_started_service')")
+ started_futures = set()
+ self.stop_service()
+ try:
+ raise cast(Exception, exception[0])
+ except Exception as e:
+ logging.getLogger("exception").exception("Uncaught exception: {}".format(str(e)))
else:
self.logger.warning("No transports defined in service file")
self.stop_service()
