使用配置了 redis 后端的 celery 获得了一个 python 应用程序,并且正在使用主管启动服务。问题是,我的 Redis 密码中有一个哈希#
字符,因此出现如下错误
Traceback (most recent call last):
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/worker/__init__.py", line 206, in start
self.blueprint.start(self)
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/bootsteps.py", line 119, in start
self.on_start()
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/apps/worker.py", line 169, in on_start
string(self.colored.cyan(' \n', self.startup_info())),
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/apps/worker.py", line 230, in startup_info
results=self.app.backend.as_uri(),
File "/home/apps/venv/my_app/lib/python3.5/site-packages/kombu/utils/__init__.py", line 325, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/app/base.py", line 626, in backend
return self._get_backend()
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/app/base.py", line 445, in _get_backend
return backend(app=self, url=url)
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/backends/redis.py", line 92, in __init__
self.connparams = self._params_from_url(url, self.connparams)
File "/home/apps/venv/my_app/lib/python3.5/site-packages/celery/backends/redis.py", line 109, in _params_from_url
scheme, host, port, user, password, path, query = _parse_url(url)
File "/home/apps/venv/my_app/lib/python3.5/site-packages/kombu/utils/url.py", line 24, in _parse_url
return (scheme, unquote(parts.hostname or '') or None, parts.port,
File "/usr/lib/python3.5/urllib/parse.py", line 158, in port
port = int(port, 10)
ValueError: invalid literal for int() with base 10: 'XdrB4'
[2017-01-06 10:05:03,224: ERROR/MainProcess] Unrecoverable error: ValueError("invalid literal for int() with base 10: 'XdrB4'",)
问题是,它XdrB4
是 Redis 密码的一部分。紧跟在 4 之后的字符是#
. 当我删除哈希时,设置工作。我不得不完全更改整个密码,但我想知道是什么原因造成的。
Redis 连接设置
redis_host = os.environ["REDIS_HOST"]
redis_name = os.environ["REDIS_DATABASE"]
redis_pass = os.environ["REDIS_PASS"]
redis_port = int(os.environ["REDIS_PORT"])
Supervisord.conf
environment =
REDIS_HOST="redis-host-ip",
REDIS_DATABASE="0",
REDIS_PASS="XdrB4#XGDc******",
REDIS_PORT="6379"
我应该逃避哈希吗?如果是这样,我用什么字符来逃避它?我试过反斜杠,双哈希等没有任何效果。
应用版本:
python3.5
celery==3.1.23
kombu==3.0.35
redis==2.10.5