Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Litestar CLI cause crash on application exit #21

Open
Forceres opened this issue Jul 14, 2024 · 3 comments
Open

Litestar CLI cause crash on application exit #21

Forceres opened this issue Jul 14, 2024 · 3 comments

Comments

@Forceres
Copy link

Litestar CLI cause crash on application exit, but when I start via granian cli, it works cool.
MCVE:

   def init_app(
    init_api_routers: Callable or None,
    structlog_config: StructLoggingConfig,
    context: str,
    middlewares: list[Middleware],
) -> Litestar:
    set_event_loop_policy(EventLoopPolicy())

    if init_api_routers is None:

        def init_api_routers():
            return []

    structlog_plugin = StructlogPlugin(StructlogConfig(structlog_logging_config=structlog_config))
    app = Litestar(
        route_handlers=[*init_api_routers()],
        middleware=middlewares,
        plugins=[structlog_plugin, GranianPlugin()],
    )
    return app


   def init_apps() -> Litestar:
    context = "schedule_service"
    structlog_config = init_logging(context)
    logger = get_logger()
    app: Litestar = init_app(
        None, structlog_config, context, [GZipMiddleware]
    )
    app.on_startup = []
    app.on_shutdown = []
    app.logger = logger
    return app


app = init_apps()
@cofin
Copy link
Owner

cofin commented Jul 17, 2024

Can you provide the traceback that you receive here? Also any info on OS and python version would be helpful.

@Forceres
Copy link
Author

No traceback, just one message
Screenshot_20240720_223533
I use python 3.11.5, and Linux Fedora 40 KDE Plasma

@Forceres
Copy link
Author

Can you provide the traceback that you receive here? Also any info on OS and python version would be helpful.

Last update fixed the problem with crash and not process exiting, but now here is a new problem with logs, some logs are output after application close in command line like here:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants