Skip to content
snim2 edited this page Oct 3, 2012 · 1 revision

How to raise file descriptor limit (on Linux)

If you get the following error, it means that the user has run out of file descriptors. You will need administrator privileges to raise this limit.

 Traceback (most recent call last):
  File "tokenring-processes.py", line 99, in <module>
  File "build/bdist.linux-i686/egg/csp/patterns.py", line 42, in __init__
  File "build/bdist.linux-i686/egg/csp/cspprocess.py", line 657, in __init__
  File "build/bdist.linux-i686/egg/csp/cspprocess.py", line 668, in _setup
  File "/usr/lib/python2.6/multiprocessing/__init__.py", line 178, in RLock
  File "/usr/lib/python2.6/multiprocessing/synchronize.py", line 142, in __init__
  File "/usr/lib/python2.6/multiprocessing/synchronize.py", line 49, in __init__
 OSError: [Errno 24] Too many open files

To check the maximum number of allowed file descriptors:

 ulimit -n

To raise this limit you need to edit the /etc/security/limits.conf file and add the following lines to the bottom of the file. NOTE you should read the comments in the file to see whether you want to limit the changes to just specific users or groups of users. The example below will change the limits for all users. NOTE2 you will also want to think about the limit and set it according to your requirements, the value in the example below is just an example.

 *		 soft	 nofile		 10000
 *		 hard	 nofile		 10000

You will need to logout and back in again before the new limit will take affect. Use ulimit -n to check that the change has been applied.

You still can't exceed the system file descriptor limit. The system limit can be discovered using:

cat /proc/sys/fs/file-max

You can temporarily raise this limit using (replace NEW-LIMIT with the new limit):

echo NEW-LIMIT >  /proc/sys/fs/file-max

To make this change persistent across reboots you can add the following line to /etc/sysctl.conf (replace NEW-LIMIT with the new limit):

fs.file-max = NEW-LIMIT

How to raise file descriptor limit (on Mac)

http://krypted.com/mac-os-x/maximum-files-in-mac-os-x/

http://siculars.posterous.com/sad-face-too-many-open-files

Thanks to Tony Heskett!

Pulling out the important bits of the above and other webpages elsewhere.

Edit /etc/launchd.conf to ensure there is a setting of the maxfiles property, so for example:

limit maxfiles 1024 unlimited

and reboot. This sets the kernel limit but not the shell limit. At the command line:

ulimit -S -n 1024

sets the shell limit.

How to package Jython programs as Jar files

http://stackoverflow.com/questions/1252965/distributing-my-python-scripts-as-jars-with-jython