I have a problem with open files under my Ubuntu 9.10 when running server in Python2.6 And main problem is that, that i don\'t know why it so..
I have set
Params that configure max open connections.
at /etc/sysctl.conf
add:
net.core.somaxconn=131072
fs.file-max=131072
and then:
sudo sysctl -p
at /usr/include/linux/limits.h
change:
NR_OPEN = 65536
at /etc/security/limits.conf
add:
* soft nofile 65535
* hard nofile 65535
If you are using supervisord to run your process, nothing mentioned above will work. That happens because supervisord has its own configuration for the limit of opened files of its processes.
On /etc/supervisord.conf
[supervisord]
...
minfds=1024;
You can also do this from your python code like below
import resource
resource.setrlimit(resource.RLIMIT_NOFILE, (65536, 65536))
The second argument is tuple (soft_limit, hard_limit)
. The hard limit is the ceiling for the soft limit. The soft limit is what is actually enforced for a session or process. This allows the administrator (or user) to set the hard limit to the maximum usage they wish to allow. Other users and processes can then use the soft limit to self-limit their resource usage to even lower levels if they so desire.