[Twisted-Python] how to abort a Protocol connection

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Sun Sep 26 22:39:00 EDT 2010


On 26 Sep, 06:23 am, xieweikai at gmail.com wrote:
>Folks,
>    I have a usage case where the server need to abort a client TCP
>connection (implemented by Protocol) immediately. However, the normal
>Protocol.transport.loseConnection() will try to send pending data to
>the client first before close the connection.
>    Currently I used an ugly hack to work around it, where I set
>Protocol.transport._writeDisconnected=True before call
>Protocol.transport.loseConnection() , which can fool the
>loseConnection to  give up writing pending data. But I think there
>should be some more elegant way to do it. Any idea?

Unfortunately the best answer I have is a reference to an open ticket:

  http://twistedmatrix.com/trac/ticket/78

The feature you want seems to be largely implemented in a branch 
associated with that ticket, but seems to be blocked by some Windows/SSL 
issues.

Jean-Paul



More information about the Twisted-Python mailing list