Merge pull request #427 from agoose77/trigger_cleanup

Simplify trigger events (now guaranteeed to receive list of events)
This commit is contained in:
Eli Uriegas 2017-02-14 09:34:34 -06:00 committed by GitHub
commit dddc18d77c

View File

@ -256,13 +256,10 @@ def trigger_events(events, loop):
:param events: one or more sync or async functions to execute :param events: one or more sync or async functions to execute
:param loop: event loop :param loop: event loop
""" """
if events: for event in events:
if not isinstance(events, list): result = event(loop)
events = [events] if isawaitable(result):
for event in events: loop.run_until_complete(result)
result = event(loop)
if isawaitable(result):
loop.run_until_complete(result)
def serve(host, port, request_handler, error_handler, before_start=None, def serve(host, port, request_handler, error_handler, before_start=None,