Skip to content

Commit b077467

Browse files
committed
[config] Live reload of setup.cfg
This code allows to reload the setup.cfg everytime the method `get_conf` in the class `Config` is called. Signed-off-by: Valerio Cosentino <[email protected]>
1 parent 52c722f commit b077467

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sirmordred/config.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import configparser
2424
import logging
25+
from threading import Lock
2526

2627
from sirmordred._version import __version__
2728

@@ -41,6 +42,8 @@
4142
class Config():
4243
"""Class aimed to manage sirmordred configuration"""
4344

45+
config_lock = Lock()
46+
4447
def __init__(self, conf_file, conf_list=[]):
4548
"""Initialize object.
4649
@@ -654,8 +657,11 @@ def create_config_file(cls, file_path):
654657
parser.write(f)
655658

656659
def get_conf(self):
657-
# TODO: Return a deepcopy to avoid uncontrolled changes in config?
658-
return self.conf
660+
"""Reload configuration files"""
661+
662+
with self.config_lock:
663+
self.__read_conf_files()
664+
return self.conf
659665

660666
def set_param(self, section, param, value):
661667
""" Change a param in the config """

0 commit comments

Comments
 (0)