Close inactive connections in Twisted
问题 I'm running a Twisted server with the LineReceiver protocol. Sometimes clients will disconnect silently, so Twisted keeps the connection open. And because the server doesn't send anything unless requested of it, there's never a TCP timeout. In other words, some connections are never closed server-side. How can I have Twisted close a connection that's been inactive for a few hours? 回答1: You can schedule timed events using reactor.callLater . Based on this, there's a helper for adding timeouts