【问题标题】:How to pass connection details in Celery如何在 Celery 中传递连接详细信息
【发布时间】:2014-10-22 20:31:11
【问题描述】:

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

我试过这个:

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

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

【问题讨论】:

    标签: python django python-3.x celery


    【解决方案1】:

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

    从对象读取配置,其中对象是对象或 要导入的模块的名称。

    例如:

    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')
    

    【讨论】:

      猜你喜欢
      • 2013-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 2020-05-06
      • 1970-01-01
      • 2014-09-03
      相关资源
      最近更新 更多