[Buildbot-devel] modules, reconfig, lazy_reload & a better alternative?
Vitali Lovich
vlovich at gmail.com
Fri Jan 23 18:15:55 UTC 2015
Hey,
I was trying to find a way to keep my buildbot organized into modules like a regular project
but not lose the functionality of reconfig & whatnot like one normally would.
I stumbled across https://github.com/dabrahams/bbproto <https://github.com/dabrahams/bbproto> & the lazy-reload links.
However, I was unhappy with lazy reload as it seemed like I would have to annotate that everywhere
I load one of my modules, I need to lazy-reload it. Additionally, it’s unclear how that works well with complex dependencies
(it seems like modules would keep getting reloaded multiple times which would have its own headaches & possibly bugs)
From my prototyping, this seems like a much better solution. Are there any problems? I haven’t tried it out with buildbot yet.
import os
import sys
codebase_dir = os.path.dirname(os.path.abspath(__file__))
modules_to_delete = [name for name, module in sys.modules.iteritems() if hasattr(module, '__file__') and module.__file__.startswith(codebase_dir)]
for module in modules_to_delete:
del sys.modules[module]
Basically, this is in the master.cfg before I load any modules. The master.cfg is at the top-level directory of all other python files I might import.
So the master.cfg basically unloads any modules that are in my project.
Thoughts?
-Vitali
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20150123/19dac13c/attachment.html>
More information about the devel
mailing list