Skip to content

aria2_server.app.lifespan

__all__ module-attribute

__all__ = ('context', 'lifespans')

lifespans module-attribute

lifespans: List[_LifespanType] = [
    _init_db,
    _init_superuser_in_db,
    Aria2WatchdogLifespan,
]

We provide this list for you to append your own lifespan events, but you cannot modify the existing events.

context

context() -> Generator[None, None, None]

Launch the all lifespans in the lifespans list.

Source code in src/aria2_server/app/lifespan/__init__.py
@contextmanager
def context() -> Generator[None, None, None]:
    """Launch the all lifespans in the `lifespans` list."""
    with ExitStack() as stack:
        for lifespan in lifespans:
            stack.enter_context(lifespan())
        yield