Prepare for v23.6 release (#2797)
This commit is contained in:
@@ -1 +1 @@
|
||||
__version__ = "23.3.1"
|
||||
__version__ = "23.6.0"
|
||||
|
||||
@@ -38,3 +38,15 @@ class ExceptionMixin(metaclass=SanicMeta):
|
||||
return handler
|
||||
|
||||
return decorator
|
||||
|
||||
def all_exceptions(self, handler):
|
||||
"""
|
||||
This method enables the process of creating a global exception
|
||||
handler for the current blueprint under question.
|
||||
|
||||
:param handler: A coroutine function to handle exceptions
|
||||
|
||||
:return a decorated method to handle global exceptions for any
|
||||
route registered under this blueprint.
|
||||
"""
|
||||
return self.exception(Exception)(handler)
|
||||
|
||||
@@ -4,7 +4,7 @@ from typing import Any, Callable, Dict, Optional, Set, Union
|
||||
from sanic.base.meta import SanicMeta
|
||||
from sanic.models.futures import FutureSignal
|
||||
from sanic.models.handler_types import SignalHandler
|
||||
from sanic.signals import Signal
|
||||
from sanic.signals import Event, Signal
|
||||
from sanic.types import HashableDict
|
||||
|
||||
|
||||
@@ -80,3 +80,9 @@ class SignalMixin(metaclass=SanicMeta):
|
||||
|
||||
def event(self, event: str):
|
||||
raise NotImplementedError
|
||||
|
||||
def catch_exception(self, handler):
|
||||
async def signal_handler(exception: Exception):
|
||||
await handler(self, exception)
|
||||
|
||||
self.signal(Event.SERVER_LIFECYCLE_EXCEPTION)(signal_handler)
|
||||
|
||||
@@ -230,14 +230,6 @@ class SignalRouter(BaseRouter):
|
||||
if not trigger:
|
||||
event = ".".join([*parts[:2], "<__trigger__>"])
|
||||
|
||||
try:
|
||||
# Attaching __requirements__ and __trigger__ to the handler
|
||||
# is deprecated and will be removed in v23.6.
|
||||
handler.__requirements__ = condition # type: ignore
|
||||
handler.__trigger__ = trigger # type: ignore
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
signal = super().add(
|
||||
event,
|
||||
handler,
|
||||
|
||||
Reference in New Issue
Block a user