Search code examples
pythoncelerypyramid

Celery doesn't recognize environment variable BROKER_URL


currently I am trying to run a Celery task within a pyramid file using pycelery with a Redis url which itself is an environment variable, so I try declaring it as follows
[celery]
BROKER_URL = ${REDIS_URL}

but when I run it I get the error enter image description here

which suggests that the BROKER_URL isn't recognizing the environment variable. But earlier in the file I'm able to declare
redis.url = ${REDIS_URL} just fine . Any help would be appreciated. Thanks!


Solution

  • Unfortunately INI setting parsing is not harmonized across Python applications and libaries. The environment variable expansion usually happens on library level, not on INI parsing level.

    Thus, pyramid_redis supports environment variables. But unless pyramid_celery adds explicit environment variable support, it doesn't happen.

    pyramid_celery repository is here. I suggest you add an issue regarding this. Meanwhile you can either configure Celery by hand in Python code (not using ini) or use hardcoded value.