gpt4 book ai didi

Django celery 4 - ValueError : invalid literal for int() with base 10 when start celery worker

转载 作者:行者123 更新时间:2023-12-01 22:59:52 25 4
gpt4 key购买 nike

我已将 celery.py 配置为其文档,但我将 celery 代理 URL 放入 AWS SQS,但无法启动它工作。当我运行 celery 工作程序时,我得到的 ValueError 为:

    File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/bin/base.py", line 244, in __call__      ret = self.run(*args, **kwargs)    File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/bin/worker.py", line 255, in run      **kwargs)    File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/worker/worker.py", line 99, in __init__      self.setup_instance(**self.prepare_args(**kwargs))    File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/worker/worker.py", line 120, in setup_instance      self._conninfo = self.app.connection_for_read()    File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/app/base.py", line 752, in connection_for_read      return self._connection(url or self.conf.broker_read_url, **kwargs)    File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/app/base.py", line 828, in _connection      'broker_connection_timeout', connect_timeout    File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/kombu/connection.py", line 181, in __init__      url_params = parse_url(hostname)    File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/kombu/utils/url.py", line 34, in parse_url      scheme, host, port, user, password, path, query = _parse_url(url)    File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/kombu/utils/url.py", line 52, in url_to_parts      parts.port,    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/parse.py", line 167, in port      port = int(port, 10)    ValueError: invalid literal for int() with base 10: 'xi'

我一直在四处寻找,但似乎不知道如何解决这个问题。这个你能帮我吗!非常感激!

最佳答案

我遇到了同样的问题,并已解决。

首先检查(很可能)您的 AWS 访问 key ID 或 secret key 是否在某处包含“xi/”,并且您拥有:

BROKER_URL = "sqs://%s:%s@" % (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

如果是这样,那么您的问题出在 URL 不安全 key 上,解决方法是:

BROKER_URL = 'sqs://{0}:{1}@'.format(
urllib.parse.quote(AWS_ACCESS_KEY_ID, safe=''),
urllib.parse.quote(AWS_SECRET_ACCESS_KEY, safe='')
)

注意:如果使用 Python 2.x,请使用 urllib.quote

关于Django celery 4 - ValueError : invalid literal for int() with base 10 when start celery worker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49417851/

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