python 资源限制
python resource limits
subprocess.Popen..的使用有限制吗?我观察到它在第 1017 次执行外部命令时连续失败。
用法:
subprocess.Popen (cmd, shell=True, stdout=file_hndl, stderr=file_hndl)
期望错误和输出被重定向到文件对象 file_hndl
您 运行 没有文件句柄。你可以增加它并检查;
更多信息在这里
https://unix.stackexchange.com/questions/36841/why-is-number-of-open-files-limited-in-linux
https://unix.stackexchange.com/questions/84227/limits-on-the-number-of-file-descriptors
subprocess.Popen没有错,是用file_hndl
代替stdout
和[=12造成的破坏=].
所有资源仅限于操作系统中的每个用户进程。
例如:On Linux
$ ulimit -a
核心文件大小(块,-c)0
数据段大小(千字节,-d)无限制
调度优先级 (-e) 0
文件大小(块,-f)无限制
挂起信号 (-i) 30254
最大锁定内存(千字节,-l)64
最大内存大小(千字节,-m)无限制
打开文件 (-n) 1024
注意可以打开的文件数是 1024,这限制了 subprocess.Popen
的执行。
使用 resource.setrlimit 根据需要设置资源限制。
例如:resource.setrlimit (resource.RLIMIT_NOFILE, (20000,20000))
subprocess.Popen..的使用有限制吗?我观察到它在第 1017 次执行外部命令时连续失败。
用法:
subprocess.Popen (cmd, shell=True, stdout=file_hndl, stderr=file_hndl)
期望错误和输出被重定向到文件对象 file_hndl
您 运行 没有文件句柄。你可以增加它并检查; 更多信息在这里
https://unix.stackexchange.com/questions/36841/why-is-number-of-open-files-limited-in-linux https://unix.stackexchange.com/questions/84227/limits-on-the-number-of-file-descriptors
subprocess.Popen没有错,是用file_hndl
代替stdout
和[=12造成的破坏=].
所有资源仅限于操作系统中的每个用户进程。
例如:On Linux
$ ulimit -a
核心文件大小(块,-c)0
数据段大小(千字节,-d)无限制
调度优先级 (-e) 0
文件大小(块,-f)无限制
挂起信号 (-i) 30254
最大锁定内存(千字节,-l)64
最大内存大小(千字节,-m)无限制
打开文件 (-n) 1024
注意可以打开的文件数是 1024,这限制了 subprocess.Popen
的执行。
使用 resource.setrlimit 根据需要设置资源限制。
例如:resource.setrlimit (resource.RLIMIT_NOFILE, (20000,20000))