socket.accept error 24: To many open files

前端 未结 3 608
予麋鹿
予麋鹿 2020-12-12 21:11

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

相关标签:
3条回答
  • 2020-12-12 21:47

    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
    
    0 讨论(0)
  • 2020-12-12 21:47

    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;
    
    0 讨论(0)
  • 2020-12-12 22:10

    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.

    0 讨论(0)
提交回复
热议问题