Add better error message around app.loop

This commit is contained in:
Eli Uriegas 2017-02-18 12:29:25 -06:00
parent c75d484f23
commit 2c2a28e46b

View File

@ -57,11 +57,14 @@ class Sanic:
@property @property
def loop(self): def loop(self):
"""Synonymous with asyncio.get_event_loop().""" """Synonymous with asyncio.get_event_loop().
Only supported when using the `app.run` method.
"""
if not self.is_running: if not self.is_running:
raise SanicException( raise SanicException(
'Loop can only be retrieved after the app has started ' 'Loop can only be retrieved after the app has started '
'running or when not run asynchronously') 'running. Not supported with `create_server` function')
return get_event_loop() return get_event_loop()
# -------------------------------------------------------------------- # # -------------------------------------------------------------------- #