Move server.py into its own module (#2230)

* Move server.py into its own module

* Change monkeypatch path on test_logging.py
This commit is contained in:
Adam Hopkins
2021-08-31 11:51:32 +03:00
committed by GitHub
parent 9d0b54c90d
commit 945885d501
11 changed files with 951 additions and 890 deletions

16
sanic/server/events.py Normal file
View File

@@ -0,0 +1,16 @@
from inspect import isawaitable
from typing import Any, Callable, Iterable, Optional
def trigger_events(events: Optional[Iterable[Callable[..., Any]]], loop):
"""
Trigger event callbacks (functions or async)
:param events: one or more sync or async functions to execute
:param loop: event loop
"""
if events:
for event in events:
result = event(loop)
if isawaitable(result):
loop.run_until_complete(result)