Solve python OSError: [Errno 24] Too many open files: ‘/dev/urandom’


When you’re using random intensively, then at some conditions, you will get this errors:

1
OSError: [Errno 24] Too many open files: ‘/dev/urandom’

And this will makes another tasks that need to generate random getting affected.

To solve this issue, you need to raise OS-level limitation of /dev/random or /dev/urandom. I use Fedora 17 at this example, which this limitation is handle by:

1
/etc/security/limit.conf

And you can modify it:

1
2
3
4
#<domain>      <type>  <item>         <value>
#
*               soft     nofile          65535
*               hard     nofile          65535

Unfortunately, you need to reboot server to make OS obey this limitation and opening access for 65535 request to /dev/random or /dev/urandom.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.