Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate Flask with Faust

I'm trying to get a faust agent to cast a message inside a flask view/endpoint, I can't find any example of it and i'm really struggling.

Has anyone tried this successfully? the docs say to use gevent or eventlet as a bridge to asyncio but can't understand how unfortunately

like image 339
shipperizer Avatar asked Nov 07 '22 18:11

shipperizer


1 Answers

You can try to monkeypatch your flask application with gevent or eventlet. As far as I know eventlet is the only one which is currently working since the bridge aiogevent is no longer available in pip.

Another approach is to delegate your Flask app to only produce messages with pykafka or kafka-python. In this way you will keep both applications isolated, flask producing and faust consuming. Note that by default faust will try to create topics without internal flag with 1 replica and internal topics with 8 replicas.

like image 167
andre Avatar answered Nov 14 '22 23:11

andre