python supervisord escape hash (#)

465 views Asked by At

Got a python app using celery configured with a redis backend and am using supervisor to start the services. Issue is, my Redis password has got a hash # character in it and as such am getting an error as below

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

Thing is, the XdrB4 is part of the Redis password. The character immediately after the 4 is a #. When I remove the hash the setup works. I've had to change the whole password altogether but I'd like to know what could be causing it.

Redis connection settings

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"

Should I escape the hash? If so, what character do I use to escape it with? I've tried backslash, double hash etc nothing works.

App versions:

python3.5 celery==3.1.23 kombu==3.0.35 redis==2.10.5

0

There are 0 answers