Issue #5 new

CELERY_ROUTES in celery-pylons Options

Anonymous created an issue

Has anyone succeeded in using the CELERY_ROUTES configuration parameter with celery-pylons? celery-pylons does not seem to be able to parse out the dictionary structure of this variable from a standard pylons .ini file. Here is how the CELERY_ROUTES variable is set in celeryconfig.py:

CELERY_ROUTES = {"feed.tasks.import_feed": {"queue": "feeds"}}

celery-pylons translates from the variable format XXX_XXX syntax to xxx.xxx which is the pylons ini format. So the pylons .ini equivalent variable is named

celery.routes = {"feed.tasks.import_feed": {"queue": "feeds"}}

The code below does not adequately parse out the dictionary structure so I am unable to use the celery routing functionality in my pylons app. Am I missing something? Are there any plans to fix this? Below is the code that parses and translates the celery configuration variables for pylons. celery-pylons.loader.py

{{{

!python

from celery.loaders.base import BaseLoader from pylons import config import types to_pylons = lambda x: x.replace('','.').lower() to_celery = lambda x: x.replace('.', '').upper() LIST_PARAMS = """CELERY_IMPORTS ADMINS ROUTES""".split() class PylonsSettingsProxy(object): """Pylons Settings Proxy Proxies settings from pylons.config """ def getattr(self, key): pylons_key = to_pylons(key) try: value = config[pylons_key] if key in LIST_PARAMS: return value.split() return value except KeyError: raise AttributeError(pylons_key) def setattr(self, key, value): pylons_key = to_pylons(key) config[pylons_key] = value class PylonsLoader(BaseLoader): """Pylons celery loader Maps the celery config onto pylons.config """ def read_configuration(self): self.configured = True return PylonsSettingsProxy() def on_worker_init(self): """ Import task modules. """ self.import_default_modules() }}}

Comments (2)

  1. Log in to comment