[Twisted-Python] connectionLost never reached after calling loseConnection: stuck in CLOSE_WAIT forever
Stefano Debenedetti
ste at demaledetti.net
Sat Oct 16 11:22:56 EDT 2010
Hi,
I have a similar problem as described in this old mail [1] except
that I am not using threads at all.
Basically my app is a server that accepts connections from a client
(connection A), when A is established it opens connections B and C
to another server and forwards data from A to B and from C back to A.
Here is how data is forwarded:
def forward(_from, to):
_from.dataReceived = to.transport.write
to.transport.registerProducer(_from.transport, True)
def loseConnection(proto, onlost=lambda *args: None):
proto.connectionLost = onlost
proto.transport.unregisterProducer()
proto.transport.loseConnection()
as soon as connectionMade has been called on connection A, B and C:
forward(A_protocol, B_protocol)
forward(C_protocol, A_protocol)
as soon as it decides its job is done and wants to tear down all
connections:
loseConnection(B_protocol)
loseConnection(C_protocol, lambda *a: loseConnection(A_protocol))
More information about the Twisted-Python
mailing list