-
Notifications
You must be signed in to change notification settings - Fork 90
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
add Quart asgi template #1138
add Quart asgi template #1138
Conversation
@sinisaos Interesting - I've been aware of Quart for a long time, but wasn't sure how to mount a third party ASGI app. Congratulations on finding a solution 👏 |
Same thing also works with Sanic. I will create an asgi template for Sanic, but first I need to understand how Pydantic and OpenAPI docs work in Sanic. They say it's automatic, but that's not exactly true because we need to make a lot of decorators for the configuration. I will do my best. |
Using the Hypercorn middleware is a nice idea, I wasn't aware it existed. |
@dantownsend Small offtopic. If you have some time you can check this repo. I made some benchmarks for asgi drivers and ORM's. I'm not a benchmark expert, but benchmarks show that Piccolo has the best performance (by some margin) for reading data than other ORMs. I didn't consider ORM's like Ormar or SQLModel (and many others) because those ORM's are just wrappers around SQLALchemy. Other than that, Piccolo is the easiest to use, easy to configure and set up, and has many great features (still missing |
@dantownsend Yes. That feature is really useful and allows us to enable Piccolo Admin for frameworks that don't have asgi app mounting options. |
@sinisaos That's good to know, thanks! I did some optimisation work a while ago, but over time the focus has moved to adding features instead of optimisation. There is probably still lots of room for improvement. One potential 'cheat' is to use frozen queries: https://piccolo-orm.readthedocs.io/en/latest/piccolo/query_clauses/freeze.html#freeze The idea is it makes the performance of some queries closer to just writing raw SQL. In practice it doesn't save that much time, but is useful if a query is run 1000s of times. Again, it's something which could probably be optimised further. |
Yes, I do need to get around to testing those. The big PRs are challenging because I need to find a big block of time to properly review and test them. It's also challenging balancing the features which the community needs vs what I need immediately for work. Sometimes it might look like I prioritise random stuff, but it's usually something I need for a project I'm working on. I think the composite unique constraints one is probably highest priority. I have never actually needed that feature on a project, but I know a lot of people would expect it to exist. |
No worries. Piccolo already has a lot of cool features, but I see a lot of interest in those two features. A reverse lookup (in some form) would also be valuable in a situation like this where we need one less db query and it affects performance (results have better reqs/s for that endpoint with a reverse lookup). |
@dantownsend I've created a Sanic asgi template, but I'm having problems with the integration test because our dummy server doesn't start the Sanic app (which throws a Sanic exception |
I'm not sure, I haven't experimented with Sanic recently. So you can't just run it with |
Sanic has its own server, but it is also ASGI-compliant and we can use |
This looks good to me, thanks! |
@sinisaos One potential issue with this, which I only just though of, is the user has to pick Hypercorn as the server. Ideally we would not give them the option to pick a router, and just Hypercorn automatically. |
Sorry for the slow reply, I wasn't home for the weekend. I don't know if I understood correctly (the user does not have to use Hypercorn exclusively). In my case all 3 servers are working fine. |
Ah, ok - I thought it just worked with Hypercorn. I'll give it a go, thanks! |
Adding Quart asgi template. I was able to add a Piccolo admin using Hypercorn DispatcherMiddleware