The faust docs have a suggestion for integrating flask and faust. It involves using gevent
, but I do not believe it requires monkeypatching.
From the docs (https://faust.readthedocs.io/en/latest/faq.html):
This approach works with any blocking Python library that can work with gevent.
Using gevent requires you to install the aiogevent module, and you can install this as a bundle with Faust:
$ pip install -U faust[gevent]
Then to actually use gevent as the event loop you have to either use the -L option to the faust program:
$ faust -L gevent -A myproj worker -l info
or add import mode.loop.gevent at the top of your entry point script:
#!/usr/bin/env python3
import mode.loop.gevent
REMEMBER: It’s very important that this is at the very top of the module, and that it executes before you import libraries.