[Twisted-Python] Application Start Up and Tear Down

Gábor Bernáth gabor.bernath at gmail.com
Mon Jul 9 01:30:26 EDT 2007


try reactor.addSystemEventTrigger()

it calls back on system events such as startup and shutdown which are
fired by the reactor. read the details in the docs:
http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorCore.html


On 7/9/07, Pavel Bastov <pbastov at gmail.com> wrote:
> Hmm,
>
> I don't call reactor.run() explicitly.
>
> Here is how I launch it:
>
> application = service.Application('xoochat', uid = uid, gid = gid)
> internet.TCPServer(config.port,
> factory).setServiceParent(service.IServiceCollection(application))
> internet.TCPServer(3711,
> pushFactory).setServiceParent(service.IServiceCollection(application))
>
>
> On 7/9/07, Adam Atlas <adam at atlas.st> wrote:
> >
> > On 9 Jul 2007, at 00.49, Pavel Bastov wrote:
> > > 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?
> >
> > Wouldn't it work to simply handle your initialization and cleanup
> > before and after reactor.run()?
> >
> > _______________________________________________
> > Twisted-Python mailing list
> > Twisted-Python at twistedmatrix.com
> > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
> >
>
>
> --
> Best regards, Pavel Bastov
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>




More information about the Twisted-Python mailing list