From e209c99777cb30dd12fdfd0a9df1501b1ff2c8df Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Thu, 7 Jan 2021 12:06:25 +0000 Subject: [PATCH] BUILDBOT: Reload modules in master.cfg This allows buildbot reload to actually work without restarting --- buildbot-config/master.cfg | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/buildbot-config/master.cfg b/buildbot-config/master.cfg index ebb2506..fa579c1 100644 --- a/buildbot-config/master.cfg +++ b/buildbot-config/master.cfg @@ -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