类似问题的问题: Parallel Python - too many files and Python too many open files (subprocesses)
我正在使用 Parallel Python [V1.6.2] 来运行任务。该任务处理输入文件并输出日志/报告。假设有10个文件夹,每个文件夹有5000~20000个文件,并行读取、处理和写出日志。每个文件大约 50KB ~ 250KB
运行约 6 小时后,Parallel Python 失败并出现以下错误。
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 342, in __init__
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 506, in set_ncpus
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 140, in __init__
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 146, in start
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
File "/usr/lib/python2.7/subprocess.py", line 1135, in _execute_child
File "/usr/lib/python2.7/subprocess.py", line 1091, in pipe_cloexec
OSError: [Errno 24] Too many open files
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
ImportError: No module named fileutils
Original exception was:
Traceback (most recent call last):
File "PARALLEL_TEST.py", line 746, in <module>
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 342, in __init__
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 506, in set_ncpus
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 140, in __init__
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 146, in start
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
File "/usr/lib/python2.7/subprocess.py", line 1135, in _execute_child
File "/usr/lib/python2.7/subprocess.py", line 1091, in pipe_cloexec
OSError: [Errno 24] Too many open files
虽然我理解,这可能是这里http://bugs.python.org/issue2320指出的子进程中的问题,但是,似乎解决方案只是 Py V3.2 的一部分。我目前绑定到 Py V2.7。
我想知道以下建议是否有帮助:[1] http://www.parallelpython.com/component/option,com_smf/Itemid,1/topic,313.0
*) 在 /usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py 的 destroy() 方法中添加 worker.t.close()
*) 在 /usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/ppauto.py 中增加 BROADCAST_INTERVAL
我想知道 Python V2.7 中是否有可用的修复程序/解决此问题的方法。
提前致谢