From 52490025f107aed7c7cbd2f3ebc18dca41c96d43 Mon Sep 17 00:00:00 2001 From: Tobias Oberstein Date: Wed, 21 Sep 2016 07:41:27 +0200 Subject: [PATCH 1/2] fix it --- autobahn/asyncio/wamp.py | 11 ++++++++--- autobahn/twisted/wamp.py | 10 +++------- 2 files changed, 11 insertions(+), 10 deletions(-) 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..a67d487a 100644 --- a/autobahn/twisted/wamp.py +++ b/autobahn/twisted/wamp.py @@ -169,14 +169,10 @@ class ApplicationRunner(object): 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) + 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: From c3e28abe25803cc7ba195367ea4e42d97235f2bc Mon Sep 17 00:00:00 2001 From: Tobias Oberstein Date: Wed, 21 Sep 2016 07:58:14 +0200 Subject: [PATCH 2/2] make flake happy --- autobahn/twisted/wamp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autobahn/twisted/wamp.py b/autobahn/twisted/wamp.py index a67d487a..36428833 100644 --- a/autobahn/twisted/wamp.py +++ b/autobahn/twisted/wamp.py @@ -168,7 +168,7 @@ class ApplicationRunner(object): cfg = ComponentConfig(self.realm, self.extra) try: session = make(cfg) - except Exception as e: + except Exception: self.log.failure('ApplicationSession could not be instantiated: {log_failure.value}') if start_reactor and reactor.running: reactor.stop()