Giter VIP home page Giter VIP logo

litestar-granian's People

Contributors

cofin avatar dependabot[bot] avatar kienps avatar sorasful avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

litestar-granian's Issues

Litestar CLI cause crash on application exit

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()

Litestar crash when use the plugin

I'm trying to use granian using the plugin (v0.4.0) in the latest version of Litestar (v2.9.0). However, with a basic setup below:

from __future__ import annotations

from litestar import Controller, Litestar, get

from litestar_granian import GranianPlugin


class SampleController(Controller):
    @get(path="/sample")
    async def sample_route(self) -> dict[str, str]:
        """Sample Route."""
        return {"sample": "hello-world"}


app = Litestar(plugins=[GranianPlugin()], route_handlers=[SampleController])

and running litestar run, I get:

Using Litestar app from app:app
Starting Granian server process ──────────────────────────────────────────────────────────────────────────────────────────────────
┌──────────────────────────────┬──────────────────────┐
│ Litestar version             │ 2.9.0                │
│ Debug mode                   │ Disabled             │
│ Python Debugger on exception │ Disabled             │
│ CORS                         │ Disabled             │
│ CSRF                         │ Disabled             │
│ OpenAPI                      │ Enabled path=/schema │
│ Compression                  │ Disabled             │
└──────────────────────────────┴──────────────────────┘
INFO - 2024-06-10 11:17:19,358 - _granian - server - Starting granian (main PID: 6266)
INFO - 2024-06-10 11:17:19,358 - _granian - server - Listening at: http://127.0.0.1:8000

then it crashed.
However, using the granian command granian --interface asgi app:app, it works fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.