This commit is contained in:
Tobias Oberstein 2016-09-21 07:41:27 +02:00
parent 224370cd9d
commit 52490025f1
2 changed files with 11 additions and 10 deletions

View File

@ -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

View File

@ -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: