[Zope3-dev] zope.app.twisted.main and zope multiservice

Martijn Pieters mj at zopatista.com
Tue May 8 06:22:40 EDT 2007


On 5/8/07, David Pratt <fairwinds at eastlink.ca> wrote:
> Hi. I know there must be a few folks that would like to easily add other
> clients or servers to zope (at or after bootstrapping) and have control
> over the services with the running reactor :-)  A simple api for
> accessing the multiservice after bootstrapping would make zope more
> accessible to twisted development.

I'll say it again: I have had no need to access the multiservice. A
multiservice is nothing but a container that makes it convenient to
start and stop multiple services. The services themselves directly
contact the reactor, they do not depend on a multiservice for this.
The reactor is a singleton, you can import it yourself too to access
it's API if you need it's services.

In my case, I subclassed ZopeTCPServer, but that's a subclass of
twisted.application.internet.TCPServer, and all it adds is a hook to
log the service startup in the event log. I also use a dedicated
threadpool of 1 thread for the debug server, but that's a application
requirement, services use the reactor threadpool directly otherwise.

Just hold onto the services you create, and start and stop them at
will directly. Subscribe to the Zope ProcessStarting event to start
your services at Zope startup time, and use the twisted reactor
system event triggers to hook into the shutdown. You could even create
your own multiservice object to manage your own services in one go.

-- 
Martijn Pieters


More information about the Zope3-dev mailing list