[Buildbot-devel] P4Source last_change across restart

Brian Warner warner-buildbot at lothar.com
Mon Mar 5 20:36:08 UTC 2007

Scott Lamb <slamb at slamb.org> writes:

> While preparing a huge optimization to P4Source (should be in a  
> separate email, if I used darcs correctly), I noticed that its  
> self.last_change is not retained across restarts. So it always misses  
> changes that happen while it is down.

> Is there supposed to be some magic that retains state automatically?  

Alas, no.. there's currently no facility for ChangeSources to persist any
state across restarts. We could add a method to the base ChangeSource class
like "save_something" and "load_something", and have them write to a pickle
in the master's basedir for now.. then later when we move to the SQL backend
we could have those methods write to something in the database instead.

> If so, it's not working. I see this (related?) magic "compare_attrs"  
> property, but I'm not sure exactly what it does or how it's supposed  
> to work.

The compare_attrs list is used when reloading the config file, to decide if
you've changed something. Each ChangeSource (and Scheduler and Builder and
status target, etc) in the new master.cfg file is compared against the
corresponding instances that are currently active. If an equivalent object is
already active, we leave it alone. If not, then we activate the one from the
config file. If there is an active object that does not have an equivalent in
the config file, we deactivate it. This lets us leave services (like
PeriodicSchedulers or IRC bots) running as much as possible, to minimize
disruption. (if you don't change the IRC bot, it doesn't get touched. if you
do, the old one is shut off and the new one reconnects)

The __cmp__ method compares all of the attributes listed in compare_attrs
when making these equality tests. So the rule is that everything that gets
mentioned in the config file needs to have a compare_attrs list that includes
all of its constructor arguments.


More information about the devel mailing list