Hi all,

I'm facing a strange behavior when trying to create Django_rq queues 
configuration dynamically from an environment variable.

my env var is :

CUSTOM_QUEUES=default:q1:q2

into my settings.py I have:

from getenv import env



# Cache
CACHES_DEFAULT = "redis://127.0.0.1:6379/1"
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": env("CACHE_URL", CACHES_DEFAULT),
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
        },
        'TIMEOUT': 3600
    },
}


RQ_QUEUES_REDIS = {'USE_REDIS_CACHE': 'default'}
RQ_QUEUES = {k:RQ_QUEUES_REDIS for k in env('CUSTOM_QUEUES', "default").
split(':')}



I'm expecting the denerated RQ_QUEUES dict to be like this one which is 
working :

RQ_QUEUES = {
    'default': {
        'USE_REDIS_CACHE': 'default',
    },
    'q1': {
        'USE_REDIS_CACHE': 'default',
    },
    'q2': {
        'USE_REDIS_CACHE': 'default',
    },
}


even though the configuration seems to run well and I can see the queues 
from django_rq web page, my workers cannot connect and actually throw this 
error as like there's no queue key in redis


Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File 
"/home/work/virtualenv/runaway_dev/lib/python3.6/site-packages/django/core/management/__init__.py"
, line 350, in execute_from_command_line
    utility.execute()
  File 
"/home/work/virtualenv/runaway_dev/lib/python3.6/site-packages/django/core/management/__init__.py"
, line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/work/virtualenv/runaway_dev/lib/python3.6/site-packages/django/core/management/base.py"
, line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File 
"/home/work/virtualenv/runaway_dev/lib/python3.6/site-packages/django/core/management/base.py"
, line 399, in execute
    output = self.handle(*args, **options)
  File 
"/home/work/virtualenv/runaway_dev/lib/python3.6/site-packages/django_rq/management/commands/rqworker.py"
, line 79, in handle
    queues = get_queues(*args)
  File 
"/home/work/virtualenv/runaway_dev/lib/python3.6/site-packages/django_rq/queues.py"
, line 166, in get_queues
    queue_params = QUEUES[queue_names[0]]
KeyError: 'default'

By The Way: if I use the Static configuration above it just works well, so 
my suspect is more focused on Django_rq not creating the queues but maybe 
I'm also doing something unproper on the settings of Django. 

Any help would be really appreciated. thanks.

F.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f7e48f76-4120-4bbe-a5b7-d6de7d699eb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to