更改 Windows 中打开文件的最大数量 [英] change the maximum number of open files in Windows

查看:641
本文介绍了更改 Windows 中打开文件的最大数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何更改 Windows 中打开的最大文件数.类似于 unix 下的 ulimit 命令.在我的 c:\windows\system32 下,我找不到 CONFIG.NT 文件,因此更改 CONFIG.NT 文件中的文件号对我不起作用.

I would like to know how I can change the maximum number of open files in Windows. Similar to ulimit command under unix. Under my c:\windows\system32, I cannot find the CONFIG.NT file, thus changing the file number in CONFIG.NT file won't work for me.

问题是我写了一个 python 脚本,我需要在其中调用 subprocess.Popen(cmd, stdout=sp.PIPE, stdin=sp.PIPE, shell = True) 256 或 512 次.这意味着我需要启动 256 或 512 个后台进程.只要启动的进程数小于 255,脚本就可以正常工作.

The problem is I wrote a python script, in which I need to call subprocess.Popen(cmd, stdout=sp.PIPE, stdin=sp.PIPE, shell = True) 256 or 512 times. That means I need to launch 256 or 512 background processes. The script works fine whenever the number of launched process is smaller than 255.

推荐答案

这是一个老问题,但我会做出贡献.有一个限制,但它不是每个子进程的限制.Python 为每个子进程上的每个管道打开文件描述符.您的代码在 255 处中断,因为 Window 的默认限制为 512 个打开的文件描述符(非常接近 2 个管道 x 255 个子进程).

This is an old question, but I'll contribute. There is a limit, but it's not a limit of subprocesses per-say. Python opens file descriptors for each pipe on each subprocess. Your code is breaking at 255 because Window has a default limit of 512 open file descriptors (pretty close to the 2 pipes x 255 subprocesses).

请参阅此问题中的答案 3:为什么 python 有限制用于文件句柄计数?.此答案显示了如何增加 Window 的默认限制.您可以将每个 Windows 限制的打开限制更改为最多 2048 个.

See answer 3 in this question: Why python has limit for count of file handles?. This answer shows how to increase Window's default limit. You can change open limit to a max of 2048 per Windows limits.

这篇关于更改 Windows 中打开文件的最大数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆