RFC/1630 Signals (#2042)

* Temp working version of initial signal api

* fix signals router finalizing

* Additional tests

* Add event test

* finalize test

* remove old comment

* Add some missing annotations

* multiple apps per BP support

* deepsource?

* rtemove deepsource

* nominal change

* fix blueprints test

* trivial change to trigger build

* signal docstring

* squash

* squash

* Add a couple new tests

* Add some suggestions from review

* Remove inaccessible code

* Change where to condition
This commit is contained in:
Adam Hopkins
2021-03-14 10:09:07 +02:00
committed by GitHub
parent 1165663ec1
commit 824f41d6e0
16 changed files with 658 additions and 59 deletions

View File

@@ -1,10 +1,11 @@
from pathlib import PurePath
from typing import Iterable, List, NamedTuple, Optional, Union
from typing import Dict, Iterable, List, NamedTuple, Optional, Union
from sanic.models.handler_types import (
ErrorMiddlewareType,
ListenerType,
MiddlewareType,
SignalHandler,
)
@@ -50,3 +51,9 @@ class FutureStatic(NamedTuple):
host: Optional[str]
strict_slashes: Optional[bool]
content_type: Optional[bool]
class FutureSignal(NamedTuple):
handler: SignalHandler
event: str
condition: Optional[Dict[str, str]]

View File

@@ -7,7 +7,6 @@ from sanic.response import BaseHTTPResponse, HTTPResponse
Sanic = TypeVar("Sanic")
MiddlewareResponse = Union[
Optional[HTTPResponse], Coroutine[Any, Any, Optional[HTTPResponse]]
]
@@ -23,3 +22,4 @@ ListenerType = Callable[
[Sanic, AbstractEventLoop], Optional[Coroutine[Any, Any, None]]
]
RouteHandler = Callable[..., Coroutine[Any, Any, HTTPResponse]]
SignalHandler = Callable[..., Coroutine[Any, Any, None]]