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 @@ -108,10 +108,6 @@ class RhodecodeCeleryTask(Task): log.debug('using celery proxy data to run task: %r', proxy_data) from rhodecode.config.routing import make_map - from rhodecode.config.middleware import make_pyramid_app - - # TODO: this can be done once per worker versus per task - pyramid_app = make_pyramid_app(config, **config['app_conf']) request = Request.blank('/', environ=proxy_data['environ']) request.user = AuthUser(user_id=proxy_data['auth_user']['user_id'], 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 @@ -86,3 +86,7 @@ class PylonsLoader(BaseLoader): Import task modules. """ self.import_default_modules() + from rhodecode.config.middleware import make_pyramid_app + + # adding to self to keep a reference around + self.pyramid_app = make_pyramid_app(config, **config['app_conf'])