serverpython-asynciopython-3.7quarthypercorn

Why run Quart app with Hypercorn / isn't it automatic?


If you inspect the Quart library, app.run() just establishes some config and then uses asyncio.run(serve(self, config)), where serve comes from from hypercorn.asyncio import serve.

So even if you run a Quart app via python myapp.py, isn't it already using a Hypercorn server?

In particular, what's the difference between this and running via hypercorn myapp:app?

https://pgjones.gitlab.io/quart/deployment.html

It is not recommended to run Quart directly (via run()) in production. Instead it is recommended that Quart be run using Hypercorn or an alternative ASGI server. Hypercorn is installed with Quart and is used to serve requests by default (e.g. with run()).

So it sounds like, even though Hypercorn is used to serve requests by default with run(), it is not recommended to use run()? Is anyone else confused?


Solution

  • So even if you run a Quart app via python myapp.py, isn't it already using a Hypercorn server?

    Yep.

    In particular, what's the difference between this and running via hypercorn myapp:app?

    I want to reserve the run method for development so that it can by default make decisions that are beneficial for development, but bad for production. An example at the moment is that the run method uses the reloader (reloads the app whenever the code changes) by default, which is great when developing but a performance issue in production. Another example is that the run method will not use multiple workers, which again leads to worse performance in production.

    (I am the Quart author)