0

I'm looking a good way to run a none async lib inside a faust agent :

@app.agent(topic)
async def cp_agent(cp_stream):
    async for batch in cp_stream.take(100, within=5):
        print("------ Indexing a CPE  BATCH -----")
        [... Here Use of A NONE Async Function like elastic-dsl]

I read the post Adding Faust to your Existing Architecture I deduce we need to use only IO/Async library inside faust. There is now way to make a none async lib into faust ? I saw some monkey patching with : (gevent and eventlet) but seems to not working

1 Answers1

0

Short answer: no, you can't use blocking libraries inside faust. Use async/await support in the official python library or usesome thing like aioelasticsearch.

Logn answer: yes, you can, it is quite easy to start, but

Dig in this How to use asyncio with existing blocking library? to find a solution. But read carefully first answer to this asyncio, wrapping a normal function as asynchronous.

Please, think twice before start a long answer solution.

valentinmk
  • 597
  • 7
  • 18