[Twisted-Python] ClientFactory: implementing Request/Response with a persistent connection

Johann Borck johann.borck at densedata.com
Thu Feb 3 15:26:13 MST 2011


On 02/03/2011 02:01 AM, Wolfgang Powisch wrote:
> Hello,
>
> I need to talk to a Line-based TCP service from a Twisted Application.
> The remote server will accept requests and send a response.
>
> I do NOT want to open a NEW TCP-Connection for each request.

Hi,
you only have to avoid closing the connection after your first 
request/response pair, which you would otherwise do by calling 
self.transport.loseConnection() in your protocol. Twisted doesn't make 
that decision for you. Of course it also depends on the server/protocol 
supporting it.

Then there's a project called txconnpool at 
http://pypi.python.org/pypi/txconnpool, maybe it does what you want.

regards,
Johann





More information about the Twisted-Python mailing list