diff --git a/autobahn/asyncio/wamp.py b/autobahn/asyncio/wamp.py index e2e9a339..8e613299 100644 --- a/autobahn/asyncio/wamp.py +++ b/autobahn/asyncio/wamp.py @@ -78,6 +78,8 @@ class ApplicationRunner(object): connecting to a WAMP router. """ + log = txaio.make_logger() + def __init__(self, url, realm, extra=None, serializers=None, ssl=None): """ :param url: The WebSocket URL of the WAMP router to connect to (e.g. `ws://somehost.com:8090/somepath`) @@ -121,9 +123,12 @@ class ApplicationRunner(object): cfg = ComponentConfig(self.realm, self.extra) try: session = make(cfg) - except Exception: - self.log.failure("App session could not be created! ") - asyncio.get_event_loop().stop() + except Exception as e: + self.log.error('ApplicationSession could not be instantiated: {}'.format(e)) + loop = asyncio.get_event_loop() + if loop.is_running(): + loop.stop() + raise else: return session diff --git a/autobahn/twisted/wamp.py b/autobahn/twisted/wamp.py index 041cb9f3..36428833 100644 --- a/autobahn/twisted/wamp.py +++ b/autobahn/twisted/wamp.py @@ -168,15 +168,11 @@ class ApplicationRunner(object): cfg = ComponentConfig(self.realm, self.extra) try: session = make(cfg) - except Exception as e: - if start_reactor: - # the app component could not be created .. fatal - self.log.error("{err}", err=e) + except Exception: + self.log.failure('ApplicationSession could not be instantiated: {log_failure.value}') + if start_reactor and reactor.running: reactor.stop() - else: - # if we didn't start the reactor, it's up to the - # caller to deal with errors - raise + raise else: return session else: