on_event.py 450 B

123456789101112131415
  1. from ..types import StartupShutdownType
  2. decorated_startup: list[StartupShutdownType] = []
  3. decorated_shutdown: list[StartupShutdownType] = []
  4. # TODO - injection? might be useful to just inject with a special event Message
  5. def on_startup(fn: StartupShutdownType) -> StartupShutdownType:
  6. decorated_startup.append(fn)
  7. return fn
  8. def on_shutdown(fn: StartupShutdownType) -> StartupShutdownType:
  9. decorated_shutdown.append(fn)
  10. return fn