BUILDBOT: Reload modules in master.cfg

This allows buildbot reload to actually work without restarting
This commit is contained in:
Le Philousophe committed 2021-01-07 12:06:25 +00:00
1 parent 125b5036e3
commit e209c99777
1 file changed
+23 -1
+23 -1
View File
@@ -7,7 +7,29 @@
#######
import os, sys
sys.path.insert(0, os.path.dirname(__file__))
import importlib
module_path = os.path.dirname(__file__)
sys.path.insert(0, module_path)
def refresh(directory):
for module in sys.modules.values():
try:
f = module.__file__
except AttributeError:
# Some modules don't have __file__ attribute
continue
try:
if os.path.commonpath([f, directory]) != directory:
continue
except ValueError:
continue
print("Reloading {0}".format(module.__name__))
importlib.reload(module)
# Refresh modules inside buildbot-config to be able to refresh configuration on reload
# Do it before importing else we will load modules twice at startup
refresh(module_path)
import config
import workers, builds, platforms, ui