Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Abort timed out connections with abortConnection()

Timed out connections are not always killed with transport.loseConnection().
Call transport.abortConnection() instead.

http://twistedmatrix.com/documents/12.2.0/core/howto/servers.html

This fixes the memory leaking issues.
  • Loading branch information...
commit 19f0e6e0d9a7a491f3c92822d96e09ced452e2f4 1 parent 19bf4ea
@varatada varatada authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 p2pool/p2p.py
View
14 p2pool/p2p.py
@@ -80,7 +80,12 @@ def connectionMade(self):
def _connect_timeout(self):
self.timeout_delayed = None
print 'Handshake timed out, disconnecting from %s:%i' % self.addr
- self.transport.loseConnection()
+ if self.transport.abortConnection is not None:
+ # Available since Twisted 11.1
+ self.transport.abortConnection()
+ else:
+ # This doesn't always close timed out connections!
+ self.transport.loseConnection()
def packetReceived(self, command, payload2):
try:
@@ -101,7 +106,12 @@ def badPeerHappened(self):
def _timeout(self):
self.timeout_delayed = None
print 'Connection timed out, disconnecting from %s:%i' % self.addr
- self.transport.loseConnection()
+ if self.transport.abortConnection is not None:
+ # Available since Twisted 11.1
+ self.transport.abortConnection()
+ else:
+ # This doesn't always close timed out connections!
+ self.transport.loseConnection()
message_version = pack.ComposedType([
('version', pack.IntType(32)),
Please sign in to comment.
Something went wrong with that request. Please try again.