Litestar – powerful, flexible, and highly performant Python ASGI framework
litestar.dev
litestar.dev
Currently using with the following,
- [SAQ](https://saq-py.readthedocs.io/en/latest/) for background workers
- [Nginx Unit](https://unit.nginx.org/) for deployment
- [Orval](https://orval.dev/) to generate FE definitions based on the API spec.
For non-API/SPA use-cases, there are Jinja and HTMX integrations. The docs (https://docs.litestar.dev/latest/) are solid - not quite Django-tier but that's the gold standard, however the reference example is too complex imo (https://github.com/litestar-org/litestar-fullstack).
https://github.com/litestar-org/awesome-litestar has a list of useful extensions - highly recommend trying it out if you are starting a new Python web project.
ASGI (Asynchronous Server Gateway Interface) is a spiritual successor to WSGI, intended to provide a standard interface between async-capable Python web servers, frameworks, and applications.Where WSGI provided a standard for synchronous Python apps, ASGI provides one for both asynchronous and synchronous apps, with a WSGI backwards-compatibility implementation and multiple servers and application frameworks. [1]
And WSGI:
The Web Server Gateway Interface (WSGI, pronounced whiskey or WIZ-ghee) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language. [2]
[1] https://asgi.readthedocs.io/en/latest/
[2] https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
If you are just needing a client what you need should be available OOTB, unless you want more hands off.
Here is also a good article for example: https://dev.to/pbaletkeman/secure-python-litestar-site-with-...
This ends up made worse if you’re using sync routes.
If you’re constrained on a resource such as a database connection pool, your framework will continue to pull http requests off the wire that a sane client will cancel and retry due to timeouts because it takes too long to get a connection out of the pool. Since there isn’t a straightforward way to cancel the execution of a route handler in every Python http framework I’ve seen exhibit this problem, the problem quickly snowballs.
This is an issue with fastapi, too- https://github.com/tiangolo/fastapi/issues/5759
Also, in Litestar Sync is a first class citizen just as much as async is.
You can see in benchmarks (that shouldnt be taken as gospel) how frameworks drop off in sync perf., where Litestar maintains both well.
https://www.reddit.com/r/starlite/comments/10xo6ra/user_show...
In Flask applications (and I suppose, Quart) you can use the `current_app` object to hold onto a service container that itself can register/retrieve services.
It's very manual, and is annoying because you have to retrieve the container and then all of your services in your handler/controller, but there's no convention nor magic (and can give you type info), so I've rolled with it.