2929from ellar .core .templating import AppTemplating , Environment
3030from ellar .core .versioning import BaseAPIVersioning , VersioningSchemes
3131from ellar .di .injector import EllarInjector
32- from ellar .events import EventHandler , RouterEventManager
3332from ellar .logger import logger
3433from ellar .types import ASGIApp , T , TReceive , TScope , TSend
3534
@@ -41,8 +40,6 @@ def __init__(
4140 self ,
4241 config : "Config" ,
4342 injector : EllarInjector ,
44- on_startup_event_handlers : t .Optional [t .Sequence [EventHandler ]] = None ,
45- on_shutdown_event_handlers : t .Optional [t .Sequence [EventHandler ]] = None ,
4643 lifespan : t .Optional [t .Callable [["App" ], t .AsyncContextManager ]] = None ,
4744 global_guards : t .List [
4845 t .Union [t .Type [GuardCanActivate ], GuardCanActivate ]
@@ -53,12 +50,6 @@ def __init__(
5350 injector , EllarInjector
5451 ), "injector must instance of EllarInjector"
5552
56- # The lifespan context function is a newer style that replaces
57- # on_startup / on_shutdown handlers. Use one or the other, not both.
58- assert lifespan is None or (
59- on_startup_event_handlers is None and on_shutdown_event_handlers is None
60- ), "Use either 'lifespan' or 'on_startup'/'on_shutdown', not both."
61-
6253 self ._config = config
6354 self ._injector : EllarInjector = injector
6455
@@ -67,15 +58,6 @@ def __init__(
6758
6859 self ._user_middleware = list (t .cast (list , self .config .MIDDLEWARE ))
6960
70- self .on_startup = RouterEventManager (
71- [] if on_startup_event_handlers is None else list (on_startup_event_handlers )
72- )
73- self .on_shutdown = RouterEventManager (
74- []
75- if on_shutdown_event_handlers is None
76- else list (on_shutdown_event_handlers )
77- )
78-
7961 self ._static_app : t .Optional [ASGIApp ] = None
8062
8163 self .state = State ()
@@ -85,12 +67,6 @@ def __init__(
8567 self .router = ApplicationRouter (
8668 routes = self ._get_module_routes (),
8769 redirect_slashes = self .config .REDIRECT_SLASHES ,
88- on_startup = [self .on_startup .async_run ]
89- if self .config .DEFAULT_LIFESPAN_HANDLER is None
90- else None ,
91- on_shutdown = [self .on_shutdown .async_run ]
92- if self .config .DEFAULT_LIFESPAN_HANDLER is None
93- else None ,
9470 default = self .config .DEFAULT_NOT_FOUND_HANDLER , # type: ignore
9571 lifespan = self .config .DEFAULT_LIFESPAN_HANDLER ,
9672 )
0 commit comments