Python的浮士德:如何启动worker运行hello world

2024-05-12 20:49:55 发布

您现在位置:Python中文网/ 问答频道 /正文

在Spyder中,我正在尝试Faust官方网站上的Hello World应用程序:

import faust

app = faust.App(
    'hello-world',
    broker='kafka://localhost:9092',
    value_serializer='raw',
)

greetings_topic = app.topic('greetings')

@app.agent(greetings_topic)
async def greet(greetings):
    async for greeting in greetings:
        print(greeting)

我启动Zookeeper和Kafka(Kafka在Spyder中工作,以消费者/制作人为例)

我被困在这个阶段开始一个工人

$ faust -A hello_world worker -l info

我在命令行中尝试了这一点,但是$ faust无法识别;我也尝试了Python解释器,但不起作用(我没想到这一切都会起作用)

我读过关于daeamonization的文章,所以我认为这与此有关,但我可以再次使用python解释器运行Kafka consumer/producer示例

多谢各位


Tags: kafkaapphelloworldasynctopic解释器greeting