[Twisted-Python] Problem with SYN_SENT's under SCO

Richard Sharp Richard.Sharp at t-online.de
Mon Aug 9 07:16:46 MDT 2004

I recently had a problem under SCO that I had to solve. The program was 
piling up open socket objects all hanging in the state of SYN_SENT. 
Eventually the maximum number of open files was exceeded and the 
application hung badly.

I eventually narrowed the problem down with a perfectly normal python 
program to trying to connect as a client to a server that is not 
listening. The first connect returns the error EINPROGRESS, the second 
connect then returns the error "Connection refused". Running a simple 
program that repeatedly tried to connect, I could use "netstat -a" to 
watch the SYN_SENT's increasing. This only appears to happen under SCO 
and even here I am not sure whether it is not version specific.

I discovered that closing the socket object after the "connection 
refused" seemed to release any open objects and removed the SYN_SENTS, 
so I changed failIfNotConnected to what you see below. There may be a 
better or more appropriate solution but this has at least got rid of my 

Version 1.3.0 internet/tcp.py from line 355:

def failIfNotConnected(self, err):
        if sys.platform[0:3] != 'sco':
            if (self.connected or
                self.disconnected or
                not (hasattr(self, "connector"))):
            if not (hasattr(self,"connector")):
        if hasattr(self, "reactor"):
            # this doesn't happens if we failed in __init__
            del self.connector


Richard Sharp

More information about the Twisted-Python mailing list