5

我正在尝试让一个浮士德代理在烧瓶视图/端点内投射一条消息,我找不到任何例子,我真的很挣扎。

有没有人成功尝试过这个?文档说使用 gevent 或 eventlet 作为 asyncio 的桥梁,但不明白多么不幸

4

2 回答 2

1

您可以尝试monkeypatch使用 gevent 或 eventlet 来处理您的烧瓶应用程序。据我所知,eventlet 是目前唯一一个正在工作的,因为桥接aiogevent在 pip 中不再可用。

另一种方法是委托您的 Flask 应用程序仅使用pykafkakafka-python生成消息。通过这种方式,您将保持两个应用程序隔离,烧瓶生产和浮士德消费。请注意,默认情况下,faust 将尝试使用 1 个副本创建不带internal标志的主题和具有 8 个副本的内部主题。

于 2019-05-03T17:30:04.423 回答
0

浮士德文档有一个整合烧瓶和浮士德的建议。它涉及使用gevent,但我不认为它需要猴子补丁。

从文档(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.
于 2019-06-12T23:11:36.220 回答