[Twisted-Python] Application Start Up and Tear Down

Pavel Bastov pbastov at gmail.com
Wed Jul 11 00:23:10 EDT 2007

Thanks all for your assistance,

the service subclassing way worked perfectly. Now I can handle several
protocols with the service and share common data among them.

On 7/9/07, glyph at divmod.com <glyph at divmod.com> wrote:
> On 05:53 am, andrew-twisted at puzzling.org wrote:
> >Pavel Bastov wrote:
> >>Hi,
> >>
> >>so far I've been using only one Factory in my application. So, all the
> >>intialization and deinitialization code was in startFactory() /
> >>stopFactory().
> >>
> >>Now I have to add another protocol with another factory. Is there a
> >>similar pair of methods for the application (server) where I can
> >>initialize resources (db pool, for example) upon startup and free them
> >>upon shutdown?
> >
> >Make your own Service subclass, and override startService/stopService.
> I just want to reinforce that this is really the *correct* answer, and
> the other suggestions (custom code before/after run(), manually calling
> addSystemEventTrigger) both tightly bind your application logic to the
> particular way your entire process starts up and shuts down, rather than
> having a discrete unit for your application.  (Think global vs. instance
> variables.)
> The service hierarchy has issues (privilegedStartService being the
> biggest one) but it is generally the most flexible, since you can start
> and stop services and groups of services without starting and stopping
> the entire process.
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Good luck,

Pavel Bastov
xooChat Evangelist and Team Leader

More information about the Twisted-Python mailing list