[Twisted-Python] how to abort a Protocol connection

Weikai Xie xieweikai at gmail.com
Sun Sep 26 02:23:05 EDT 2010

    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?


Weikai Xie

More information about the Twisted-Python mailing list