問題有類似的問題: Parallel Python - too many files和Python too many open files (subprocesses)打開的文件太多並行的Python子進程錯誤
我使用Python的並行[V1.6.2]運行的任務。該任務處理輸入文件並輸出日誌/報告。假設有10個文件夾,每個文件夾有5000〜20000個並行讀取,處理和日誌寫出的文件。每個文件約爲50KB〜250KB
運行約6小時後,並行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
*)添加worker.t.close()中的destroy()/usr/local/lib/python2.7的方法/dist-packages/pp-1.6.2-py2.7.egg/pp.py
*)在/usr/local/lib/python2.7/dist-packages/pp-1.6.2-增加BROADCAST_INTERVAL, py2.7.egg/ppauto.py
我想知道在Python V2.7中是否有修復程序可用/解決此問題。
在此先感謝
我已經離開了一些線路來銷燬作業服務器。 job_server.destroy()修復了這個問題。 – user1652054