diff --git a/rhodecode/lib/celerylib/__init__.py b/rhodecode/lib/celerylib/__init__.py --- a/rhodecode/lib/celerylib/__init__.py +++ b/rhodecode/lib/celerylib/__init__.py @@ -76,25 +76,26 @@ class RhodecodeCeleryTask(Task): request = get_current_request() - # we hook into kwargs since it is the only way to pass our data to the - # celery worker in celery 2.2 - kwargs.update({ - '_rhodecode_proxy_data': { - 'environ': { - 'PATH_INFO': request.environ['PATH_INFO'], - 'SCRIPT_NAME': request.environ['SCRIPT_NAME'], - 'HTTP_HOST': request.environ.get('HTTP_HOST', - request.environ['SERVER_NAME']), - 'SERVER_NAME': request.environ['SERVER_NAME'], - 'SERVER_PORT': request.environ['SERVER_PORT'], - 'wsgi.url_scheme': request.environ['wsgi.url_scheme'], - }, - 'auth_user': { - 'ip_addr': request.user.ip_addr, - 'user_id': request.user.user_id - }, - } - }) + if request: + # we hook into kwargs since it is the only way to pass our data to + # the celery worker in celery 2.2 + kwargs.update({ + '_rhodecode_proxy_data': { + 'environ': { + 'PATH_INFO': request.environ['PATH_INFO'], + 'SCRIPT_NAME': request.environ['SCRIPT_NAME'], + 'HTTP_HOST': request.environ.get('HTTP_HOST', + request.environ['SERVER_NAME']), + 'SERVER_NAME': request.environ['SERVER_NAME'], + 'SERVER_PORT': request.environ['SERVER_PORT'], + 'wsgi.url_scheme': request.environ['wsgi.url_scheme'], + }, + 'auth_user': { + 'ip_addr': request.user.ip_addr, + 'user_id': request.user.user_id + }, + } + }) return super(RhodecodeCeleryTask, self).apply_async( args, kwargs, task_id, producer, link, link_error, **options) diff --git a/rhodecode/lib/celerypylons/loader.py b/rhodecode/lib/celerypylons/loader.py --- a/rhodecode/lib/celerypylons/loader.py +++ b/rhodecode/lib/celerypylons/loader.py @@ -18,15 +18,16 @@ # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ +import rhodecode +from pylons import config + from celery.loaders.base import BaseLoader -from pylons import config 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 @@ -36,7 +37,7 @@ class PylonsSettingsProxy(object): def __getattr__(self, key): pylons_key = to_pylons(key) try: - value = config[pylons_key] + value = rhodecode.PYRAMID_SETTINGS[pylons_key] if key in LIST_PARAMS:return value.split() return self.type_converter(value) except KeyError: @@ -56,7 +57,7 @@ class PylonsSettingsProxy(object): def __setattr__(self, key, value): pylons_key = to_pylons(key) - config[pylons_key] = value + rhodecode.PYRAMID_SETTINGS[pylons_key] = value def __setitem__(self, key, value): self.__setattr__(key, value)