如何解决“打开文件过多”问题芭莎的错误?
我在 Max OS X 10.6.2 上使用 Bazaar v2.0.1
当我在移动大量文件/目录(超过 10,000 个)后执行提交时,我收到以下错误消息:
bzr:错误:[Errno 24] 打开:太多 打开文件:'.'
我的第一个解决方法是将提交分成几个子集。然而,这并不理想,我担心可能在某个点上,一个更改(不能分解为子集)会给我带来同样的错误。
[更新]
经过一些研究后,我发现:
它看起来像:
Errno 24“打开:打开的文件太多”
是一个Python错误。
根据苹果文档 setrlimit 系统调用中有一个名为ulimit 的 sh 内置命令,可用于更改设置。从 shell 启动的任何进程都将继承该值。
我当前的解决方法是将 ulimit -n 10240
添加到 ~/.profile。这样,当我从 shell 运行 bzr commit
时,它将能够打开 10240 个文件。我选择了 10240 个文件,因为这是 Mac OS X 中用户进程允许的最大数量。
Bazaar 似乎不需要同时打开那么多文件。我担心如果我移动更多文件,这可能会再次困扰我。这是 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
lsof
查看所有打开的文件。您可以尝试 grep 获取 bazaar 进程的 pid,或者监视打开文件的数量。请注意,您可能需要也可能不需要 root 权限才能查看与您的情况相关的所有文件/进程。
You can use
lsof
to see all open files. You might try grepping for the pid of the bazaar process, or monitoring the number of open files.Note that you may or may not need to be root to see all files / processes relevant for your situation.
如果您的 shell 支持(它是 bash 内置命令),请在运行 bazaar 之前尝试 ulimit -n 1024 (或更多)。
金克斯!编辑:您可以将其放入
~/.profile
(如果有)或~/.bash_profile
中。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
.