How to best port flask apps to v3 ? #1802
-
Hey all, with the recent release of connexion 3.0, apps now need to be run with an ASGI server. we have a bunch of flask apps where we do not use any async functions (which works ok in our current setup with WSGI). Our current setup ist to run the app in Apache, using uWSGI (where parallel request handling is achieved by multiple processes / threads). How does that translate to running the app in an ASGI server? Is there some mechanism that takes care of handling multiple parallel requests (e.g. dispatching requests to separate threads, like Assuming that we cannot (in the short term) port all apps to be actually async, what is the correct way to run blocking functions in connexion 3 / ASGI ? I'm thankful for any pointers, I could not find anything related in the Running your application section of the docs. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @paketb0te, For processes, you can set the number of workers in the ASGI server. Threads depends on the Connexion Application you use:
|
Beta Was this translation helpful? Give feedback.
Hi @paketb0te,
For processes, you can set the number of workers in the ASGI server.
Threads depends on the Connexion Application you use:
FlaskApp
: SinceFlask
is aWSGI
app instead ofASGI
, we execute any requests passed to theFlaskApp
in a thread pool (of 10 workers) automatically. If you define anasync
routes in theFlaskApp
, you're just usingFlask
async routes within a thread.AsyncApp
: TheAsyncApp
implements ASGI, so here threads are completely replaced byasyncio
.