Skip to content

Commit

Permalink
Update register events (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsil authored Jun 6, 2024
1 parent f9f3976 commit 97d6c17
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions asyncz/contrib/esmerald/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

if TYPE_CHECKING:
from esmerald.applications import Esmerald
from pydantic.typing import AnyCallable


class EsmeraldScheduler:
Expand Down Expand Up @@ -93,14 +92,15 @@ def register_events(self, app: "Esmerald") -> None:
"""
Registers the scheduler events in the Esmerald application.
"""
if app.on_startup is not None:
app.on_startup.append(self.handler.start)
else:
app.on_startup = [self.handler.start]

@app.on_event("startup")
def start_scheduler() -> None:
self.handler.start()

@app.on_event("shutdown")
def stop_scheduler() -> None:
self.handler.shutdown()
if app.on_shutdown is not None:
app.on_shutdown.append(self.handler.shutdown)
else:
app.on_shutdown = [self.handler.shutdown]

def get_scheduler(
self,
Expand Down Expand Up @@ -208,7 +208,7 @@ def add_task(self, scheduler: "SchedulerType"):
except Exception as e:
raise ImproperlyConfigured(str(e)) from e

def __call__(self, fn: "AnyCallable") -> None:
def __call__(self, fn: Any) -> None:
"""
Tricking the object into think it's being instantiated by in reality
is just returning itself.
Expand Down

0 comments on commit 97d6c17

Please sign in to comment.