Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSError: [Errno 24] Too many open files - OS Mojave

So, I'm writing a script to take a certain dataset, sample it 100 times using different random seeds, completing all these datasets and then getting the mean error. However, whenever I try to run the script I end up with the error OSError: [Errno 24] Too many open files

I don't understand what I can do to fix this (if I should do something in the script or in to the system and what). I'm using Python 3 with macOS Mojave. Anybody has a clue?

like image 666
Nocas Avatar asked Jul 01 '19 23:07

Nocas


People also ask

How do I fix too many open files on my Mac?

A simple fix for the "too many files open" limitation of Mac OS is to use the "ulimit - n" command. Curiously, the value of n appears to be critical to whether or not this command is accepted by MacOS. I've found that ulimit -n 10240 (the default is 256) works but n values higher do not.

What does Too many open files mean?

The "Too many open files" message means that the operating system has reached the maximum "open files" limit and will not allow SecureTransport, or any other running applications to open any more files. The open file limit can be viewed with the ulimit command: The ulimit -aS command displays the current limit.


1 Answers

The number of open files you're allowed can be increased by using ulimit e.g. in bash you could do: ulimit -n This will probably print out 256 meaning that at one time a maximum of 256 file descriptors are allowed to be open.

Increase the limit: ulimit -n 30000 # 30,000 open files allowed

This sort of thing is generally done on systems running something like server programs that need a file descriptor (a socket descriptor) for each concurrent connection being handled.

However, if you post the code there might be another way to fix this. It doesn't sound like you want/need multiple file descriptors open at the same time.

like image 129
Chris Avatar answered Oct 14 '22 00:10

Chris