Add flag to not load config more then one time
@@ -17,6 +17,9 @@ from . import devices as dev_cfg
from . import loggers as log_cfg
+_config_loaded = False
+
+
@contextmanager
def read_configfile(path):
"""
@@ -50,6 +53,11 @@ def load_config(config=None, from_env_var=None, config_type='yaml'):
:param config_type: 'dict' ('config' param is dict) or 'yaml' ('config' is filename of file with YAML content)
:return: None
"""
+ global _config_loaded
+
+ if _config_loaded:
+ return
+
assert (config_type == 'dict') or (config_type == 'yaml') # no other format supported yet
if not config:
if not from_env_var:
@@ -69,6 +77,8 @@ def load_config(config=None, from_env_var=None, config_type='yaml'):
load_connection_from_config(config)
load_device_from_config(config)
+ _config_loaded = True
+
def load_connection_from_config(config):
if 'NAMED_CONNECTIONS' in config:
