[Buildbot-devel] modules, reconfig, lazy_reload & a better alternative?

Mikhail Sobolev mss at mawhrin.net
Fri Jan 23 18:34:09 UTC 2015


Hi Vitali,

On Fri, Jan 23, 2015 at 10:15:55AM -0800, Vitali Lovich wrote:
> 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.
Meta buildbot (http://buildbot.buildbot.net) uses this approach:

    https://github.com/buildbot/metabbotcfg/blob/master/master.cfg#L3

Do you see any problems with it?  (Obivously, the "2nd" level modules would not
get reloaded unless they are explicitly marked so.)

-- 
Misha




More information about the devel mailing list