[Twisted-Python] Question about TAC apps and TCPClient/Server vs reactor.connect/listenTCP

Andrew Bennetts andrew at bemusement.org
Tue Dec 22 02:39:08 EST 2009


Paul Goins wrote:
[...]
> 
> Any suggestions of how to do this?  Should I be specifying only "core"
> stuff as services of the application object, and connecting the others
> via reactor.connectTCP/listenTCP as needed?  Can I add to and remove
> services from the application object once the reactor starts?

Yes, you can add and remove services from the application object once
the reactor starts.

To remove a service, use the disownServiceParent method of the service
(as suggested by the docstring of
http://twistedmatrix.com/documents/current/api/twisted.application.service.IServiceCollection.html#removeService).
The docstrings aren't 100% explicit about this, but that will stop the
service.  As you might guess, you can add services with setServiceParent
at any time too.

That said, if plain connectTCP/listenTCP are more convenient for you
than the corresponding IService implementations, then feel free to use
them instead.

-Andrew.




More information about the Twisted-Python mailing list