##// END OF EJS Templates
celery: use safe environ extraction. In few cases of executing tasks at non-pyramid level....
marcink -
r2417:51f63062 default
parent child Browse files
Show More
@@ -195,6 +195,24 b' def configure_celery(config, ini_locatio'
195 closer=None, ini_location=ini_location)
195 closer=None, ini_location=ini_location)
196
196
197
197
198 def maybe_prepare_env(req):
199 environ = {}
200 try:
201 environ.update({
202 'PATH_INFO': req.environ['PATH_INFO'],
203 'SCRIPT_NAME': req.environ['SCRIPT_NAME'],
204 'HTTP_HOST':
205 req.environ.get('HTTP_HOST', req.environ['SERVER_NAME']),
206 'SERVER_NAME': req.environ['SERVER_NAME'],
207 'SERVER_PORT': req.environ['SERVER_PORT'],
208 'wsgi.url_scheme': req.environ['wsgi.url_scheme'],
209 })
210 except Exception:
211 pass
212
213 return environ
214
215
198 class RequestContextTask(Task):
216 class RequestContextTask(Task):
199 """
217 """
200 This is a celery task which will create a rhodecode app instance context
218 This is a celery task which will create a rhodecode app instance context
@@ -226,18 +244,11 b' class RequestContextTask(Task):'
226 if req:
244 if req:
227 # we hook into kwargs since it is the only way to pass our data to
245 # we hook into kwargs since it is the only way to pass our data to
228 # the celery worker
246 # the celery worker
247 environ = maybe_prepare_env(req)
229 options['headers'] = options.get('headers', {})
248 options['headers'] = options.get('headers', {})
230 options['headers'].update({
249 options['headers'].update({
231 'rhodecode_proxy_data': {
250 'rhodecode_proxy_data': {
232 'environ': {
251 'environ': environ,
233 'PATH_INFO': req.environ['PATH_INFO'],
234 'SCRIPT_NAME': req.environ['SCRIPT_NAME'],
235 'HTTP_HOST': req.environ.get('HTTP_HOST',
236 req.environ['SERVER_NAME']),
237 'SERVER_NAME': req.environ['SERVER_NAME'],
238 'SERVER_PORT': req.environ['SERVER_PORT'],
239 'wsgi.url_scheme': req.environ['wsgi.url_scheme'],
240 },
241 'auth_user': {
252 'auth_user': {
242 'ip_addr': ip_addr,
253 'ip_addr': ip_addr,
243 'user_id': user_id
254 'user_id': user_id
General Comments 0
You need to be logged in to leave comments. Login now