Skip to content
Snippets Groups Projects
Commit 3082f60d authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

fixing celery configuration issues

parent cc7c529d
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -7,7 +7,9 @@ services:
before_script:
- pip install -e .
- pip install flake8
- echo "REDIS_HOST='redis'" > /root/f.conf
- echo "REDIS_HOST='redis'" > /root/conf.py
- echo "REDIS_PORT=7777" >> /root/conf.py
- echo "CELERY_RESULT_BACKEND='redis://redis:7777'" >> /root/conf.py
- export FRACTALIS_CONFIG=/root/f.conf
test:
......
"""This module is responsible for the establishment and configuration of a
Celery instance."""
import os
import sys
import logging
from celery import Celery
from fractalis.config import file_to_dict
def get_scripts_packages():
packages = []
......@@ -25,8 +24,13 @@ def get_scripts_packages():
app = Celery(__name__)
app.config_from_object('fractalis.config')
try:
config = file_to_dict(os.environ['FRACTALIS_CONFIG'])
app.conf.update(config)
config_file = os.environ['FRACTALIS_CONFIG']
module = os.path.splitext(os.path.basename(config_file))[0]
sys.path.append(os.path.dirname(os.path.expanduser(config_file)))
config = __import__(module).__dict__
for key in app.conf:
if (key in config and key[0] != '_'):
app.conf[key] = config[key]
except KeyError:
logger = logging.getLogger('fractalis')
logger.warning("FRACTALIS_CONFIG is not set. Using defaults.")
......
......@@ -14,12 +14,3 @@ CELERY_RESULT_BACKEND = 'redis://{}:{}'.format(REDIS_HOST, REDIS_PORT)
CELERY_TASK_TIME_LIMIT = 60 * 10
# DO NOT MODIFY THIS FILE!
def file_to_dict(abs_path):
config = {}
with open(abs_path) as f:
for line in f:
(key, value) = [s.strip() for s in line.split('=')]
config[key] = value
return config
......@@ -10,12 +10,8 @@ class TestSession(object):
@pytest.fixture(scope='module')
def app(self):
from flask import Flask
from fractalis.session import RedisSessionInterface
app = Flask('test_app')
app.config.from_object('fractalis.config')
from fractalis import app
app.testing = True
app.session_interface = RedisSessionInterface(app.config)
return app
@pytest.fixture(scope='module')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment