Async options for flask app

Rimu Atkinson rimuatkinson+usenet at gmail.com
Sun Sep 17 18:59:15 EDT 2023


Hi all,

I'm writing a fediverse server app, similar to kbin https://kbin.pub/en 
and lemmy https://join-lemmy.org/. It's like reddit except anyone can 
run a server in the same way email works. This architecture involves a 
lot of inter-server communication, potentially involving thousands of 
different servers.

So, lots of network I/O. Lots of tasks running in parallel to do I/O 
with different servers simultaneously. A fair bit of DB access too.

The current fashion is to do this with cooperative multitasking 
(async/await/gevent/etc) to avoid the overhead associated with 
continually context switching threads and processes. Correct me if I'm 
wrong.

How can I do this with Flask? Any async/await tricks? Can I just 
configure gunicorn to use gevent worker threads? 
https://flask.palletsprojects.com/en/2.3.x/deploying/gunicorn/

Has anyone tried Quart? https://pypi.org/project/quart/

How well does gevent monkey-patch into a Flask app?

A penny for your thoughts

Thanks!

R


More information about the Python-list mailing list