Search code examples
pythonbazaar

How do I resolve a "Too many open files" error in Bazaar?


I am using Bazaar v2.0.1 on Max OS X 10.6.2

When I perform a commit after moving a large number of files/directories (over 10,000) I get the following error message:

bzr: ERROR: [Errno 24] open: Too many open files: '.'

My first work-around was to break the commit up into several sub-sets. However, this is not ideal and I'm afraid there may be a point where one change (that cannot be broken up into sub-sets) will give me the same error.

[Update]

After doing some research this is what I have found:

It looks like:

Errno 24 "open: Too many open files"

is a Python error.

According to this blog post, the limit on the number of files open can be changed from within a Python script with resource.setrlimit. However, I was really looking for a way to change the default value so Bazaar would automatically run with a higher value (BTW, it looks like my default setting was 2560).

According to the apple documentation for the setrlimit system call there is a sh built-in command called ulimit which can be used to change the setting. Any process started from the shell would then inherit this value.

My current work-around is to add ulimit -n 10240 to ~/.profile. This way when I run bzr commit from the shell it will be able to open 10240 files. I selected 10240 files because this is the maximum allowed for a user process in Mac OS X.

It doesn't seem like Bazaar should need that many files open at once. I am worried that if I ever move more files that this may come back to bite me again. Is this a bug in Bazaar? Is there anything else I can do?


Solution

  • Try ulimit -n 1024 (or more) before running bazaar, if your shell supports it (it's a bash builtin).

    Jinx! edit: you can put it in your ~/.profile if there is one, or ~/.bash_profile.