[Buildbot-devel] Creating a new StatusReceiver type

Brian Warner warner-buildbot at lothar.com
Sun Nov 5 06:19:49 UTC 2006


"Eli Carter" <eli.carter at commprove.com> writes:

> And I found the answer:
>     def setServiceParent(self,parent)
>         parent.getStatus().subscribe(self)
> But setServiceParent is not in IStatusReceiver.  Shouldn't it be?  Or am I
> misunderstanding something?

Your code (and understanding) is correct.. it's the docs that are lacking.

setServiceParent (and disownServiceParent and startService and stopService)
are all methods of twisted.application.service.Service, which is like a
great-grandparent class of most of the status receiver targets. There is a
tiny amount of documentation on the Twisted website[1], but it doesn't really
cover the parts that we care about here.

Basically the Service/MultiService parent classes organize things into a
tree. Each node of the tree can access its parent through the ".parent"
attribute. You add a node to the tree by attaching it to its new parent:
child.setServiceParent(parent). You remove one by detaching it:
node.disownServiceParent().

Each node is either running or stopped. When you add a child node to a
running parent, the child starts running. When you remove it, it stops. The
startService() method gets invoked when the service switches from the stopped
to the running state, which generally means it is a safe time to use .parent
to get access to your parent. The setServiceParent method is another place
that can be used as a hook to get access to the parent.

I really need to write up an example of how to write status plugins. The
MailNotifier is a mostly-adequate example, but really some kind of tutorial
would be better.

cheers,
 -Brian


[1]: http://twistedmatrix.com/projects/core/documentation/howto/application.html




More information about the devel mailing list