Resolve tests
This commit is contained in:
parent
9e23e75fb4
commit
209579f280
13
sanic/app.py
13
sanic/app.py
|
@ -59,7 +59,6 @@ from sanic.server import (
|
|||
Signal,
|
||||
serve,
|
||||
serve_multiple,
|
||||
trigger_events,
|
||||
)
|
||||
from sanic.websocket import ConnectionClosed, WebSocketProtocol
|
||||
|
||||
|
@ -908,7 +907,7 @@ class Sanic(BaseSanic):
|
|||
)
|
||||
|
||||
# Trigger before_start events
|
||||
await trigger_events(
|
||||
await self.trigger_events(
|
||||
server_settings.get("before_start", []),
|
||||
server_settings.get("loop"),
|
||||
)
|
||||
|
@ -917,6 +916,16 @@ class Sanic(BaseSanic):
|
|||
asyncio_server_kwargs=asyncio_server_kwargs, **server_settings
|
||||
)
|
||||
|
||||
async def trigger_events(self, events, loop):
|
||||
"""Trigger events (functions or async)
|
||||
:param events: one or more sync or async functions to execute
|
||||
:param loop: event loop
|
||||
"""
|
||||
for event in events:
|
||||
result = event(loop)
|
||||
if isawaitable(result):
|
||||
await result
|
||||
|
||||
async def _run_request_middleware(self, request, request_name=None):
|
||||
# The if improves speed. I don't know why
|
||||
named_middleware = self.named_request_middleware.get(
|
||||
|
|
|
@ -147,7 +147,7 @@ class Request:
|
|||
] = defaultdict(list)
|
||||
self.uri_template: Optional[str] = None
|
||||
self.request_middleware_started = False
|
||||
self._cookies: Dict[str, str] = {}
|
||||
self._cookies: Optional[Dict[str, str]] = None
|
||||
self._match_info = {}
|
||||
self.stream: Optional[Http] = None
|
||||
self.endpoint: Optional[str] = None
|
||||
|
@ -183,8 +183,7 @@ class Request:
|
|||
response = await self.app._run_response_middleware(
|
||||
self, response, request_name=self.name
|
||||
)
|
||||
# Redefining this as a tuple here satisfies mypy
|
||||
except tuple(*CancelledErrors):
|
||||
except CancelledErrors:
|
||||
raise
|
||||
except Exception:
|
||||
error_logger.exception(
|
||||
|
|
Loading…
Reference in New Issue
Block a user