【问题标题】:Flower Http Api get Celery task detailsFlower Http Api 获取 Celery 任务详情
【发布时间】:2026-01-31 20:30:01
【问题描述】:

我有一个正在工作的芹菜花项目。
现在我想要一些使用flower http api 的 celery 失败的任务详细信息,但是我的 celery 使用--basic-auth 进行身份验证,当我在http://localhost:5555/api/tasks 上的flower http api 发出请求时,它会超时并且不显示任何结果。

我不明白这是身份验证问题还是其他问题。我看花文档,但我不知道。谢谢你的时间。以下是对我不起作用的代码。

import requests

params = (('state', 'FAILURE'),('limit', '5'),)

requests.get('http://localhost:5555/api/tasks', params=params)

【问题讨论】:

    标签: python celery flower


    【解决方案1】:

    那么您应该使用您的凭据提出请求:

    1. 导入HTTPBasicAuth(因为您使用的是--basic-auth):

      from requests.auth import HTTPBasicAuth
      
    2. 发出经过身份验证的请求:

      requests.get(
          'http://localhost:5555/api/tasks', 
          auth=HTTPBasicAuth('your_user', 'your_pass'), 
          params=params
      )
      

    祝你好运:)

    【讨论】:

    • 感谢您的快速响应,但它给了我错误 requests.exceptions.ConnectionError: HTTPSConnectionPool(host='139.172.59.25', port=5555): Max retries exceeded with url: /api/tasks?state =FAILURE&limit=5(由NewConnectionError引起(': 无法建立新连接:[Errno 110] Connection timed out',))
    • @ManishYadav 这似乎是一个不同的问题。看看这个答案:*.com/questions/23013220/… 和这个请求问题:github.com/requests/requests/issues/1198