[Twisted-Python] running several services from a single app

Allen Short washort at twistedmatrix.com
Mon Mar 28 13:44:53 EDT 2011

On Mon, Mar 28, 2011 at 8:29 AM, Aljoša Mohorović <
aljosa.mohorovic at gmail.com> wrote:

> is it possible to run several services from a single app?
> i currently have a few services/apps and would like to put them all
> into a single app so i can use cx_freeze to create a single exe file
> for windows to allow easy testing.
> Aljosa
> maybe something like this:
> --------------------------------------------------------
> factory1 = protocol.ServerFactory()
> factory1.protocol = Protocol1
> application1 = service.Application("Server1")
> internet.TCPServer(8000, factory1).setServiceParent(application1)
> factory2 = protocol.ServerFactory()
> factory2.protocol = Protocol2
> application2 = service.Application("Server2")
> internet.TCPServer(9000, factory2).setServiceParent(application2)
> reactor.listenTCP(8000, factory1)
> reactor.listenTCP(9000, factory2)
> reactor.run()

Get rid of 'application1' and 'application2' and just create a single one
named 'application' , delete the last three lines, and this code will work
just fine as a .tac file. You only need one call to 'Application' per
process, but you can have many services and many clients and servers in a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20110328/4b56e102/attachment.htm 

More information about the Twisted-Python mailing list