[Buildbot-devel] reconfig, import and exec

Brian Warner warner-buildbot at lothar.com
Sat May 12 20:00:27 UTC 2007


>> import mozbuild
>> reload(mozbuild)

Yeah, this is a consequence of the way that python handles modules. There is
a process-global cache of module contents that is only updated by the
'reload' statement. Doing the import/reload pair will flush this cache every
time the buildmaster is reconfigured.

Note that this will change the identity of any classes you've defined in that
module, so that e.g. a Builder which uses mozbuild.MyBuildStep will *always*
think it has changed, even if the contents of mozbuild.py haven't been
touched. (the cache isn't indexed by a hash of the source code).

As a result, sometimes I leave that 'reload' line commented out, and when I
need to update one of the imported modules, I do two changes. The first one
modifies mozbuild.py and uncomments the reload, so everything gets reloaded.
The second one recomments the reload statement, so that further changes (to
just the master.cfg contents) don't do the reload and don't cause spurious
side-effects (like resetting change-source pollers, or losing pending builds
that are waiting inside a Scheduler that gets replaced).

Hmm. #14 will suffer/benefit from this same effect. I was thinking we'd just
exec() all the files in master.cfg.d/* in order, in the same namespace.
Because that will change the identity of the classes, it may cause these
spurious changes. I'm not sure of a good way to deal with this.

cheers,
 -Brian




More information about the devel mailing list