gpt4 book ai didi

python - 如何在 Celery 中传递连接详细信息

转载 作者:太空宇宙 更新时间:2023-11-04 03:42:35 24 4
gpt4 key购买 nike

我如何使用 Celery 将用户和密码连接详细信息添加到我的代理。我使用的不是 Django 框架,而是 Python 3。

我试过这个:

app = Celery('tasks',
broker='sqs://123:123',
)

app.connection(
userid="23",
password="123",
transport_options="{'region': 'eu-west-1'}"
)

最佳答案

您可以使用config_from_object 方法。来自 docs :

Reads configuration from object, where object is either an object or the name of a module to import.

例如:

celeryconfig.py:

BROKER_TRANSPORT = 'amqp'
BROKER_USER = 'user'
BROKER_PASSWORD = 'password'
BROKER_HOST = 'remote.server.com'
BROKER_PORT = 123
#...

在模块中:

app = Celery('tasks')
app.config_from_object('celeryconfig')

关于python - 如何在 Celery 中传递连接详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25557934/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com