socket.error 24: too many open files

Roy Smith roy at panix.com
Thu Jan 8 00:56:31 CET 2009


In article 
<a66896a7-3fac-40c9-9051-6ae9eb2cec33 at r15g2000prh.googlegroups.com>,
 TheDavidFactor <thedavidfactor at gmail.com> wrote:

> I have double checked that it is closing the socket. I don't know what 
> else to check, any suggestions would be much appreciated.

All of the symptoms you report point to sockets not getting closed.  What 
does "double checked" mean?  Don't rely on __del__() closing sockets, 
because __del__() may never get called.

Here's a few ways to look for sockets that aren't getting closed:

1) Run netstat.

2) Look in /proc.

3) This is the cute one; iterate over all possible descriptors from 0 to 
`ulimit -n`.  For each one, dup() it, then close the dupe.  If dup() didn't 
raise an exception, the descriptor was valid.  Count the ones that don't 
fail, and you know how many descriptors are open at any time.  This is 
useful for tracking descriptor leaks (which sounds like what you've got).



More information about the Python-list mailing list