使用Process进行Python多处理:“无法创建触发管道”

时间:2015-05-22 13:37:42

标签: python process triggers multiprocessing

我正在尝试使用多处理库对我刚刚使用Python编写的代码进行多处理。 以下是我正在尝试多处理的代码部分:

for b in (Bulle):
    p=[]
    for i in range(len(X)):
        print(i,"/",len(X))
        for j in range(len(Y)):
            for n in b.voisins:
                c_pos=[X[i][j],Y[i][j]]
                if __name__ == "__main__":
                    p.append(Process(target=fonction_courant2,args=(b,n,c_pos)))
    for i in (range(len(p))): p[i].start()
    for i in (range(len(p))): p[i].join()

输出:

NotifierThreadProc: could not create trigger pipe
Traceback (most recent call last):
  File "multi_t_bubbles.py", line 113, in <module>
    for i in (range(len(p))): p[i].start()
  File "/usr/lib/python3.4/multiprocessing/process.py", line 105, in start
    self._popen = self._Popen(self)
  File "/usr/lib/python3.4/multiprocessing/context.py", line 212, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/usr/lib/python3.4/multiprocessing/context.py", line 267, in _Popen
    return Popen(process_obj)
  File "/usr/lib/python3.4/multiprocessing/popen_fork.py", line 21, in __init__
    self._launch(process_obj)
  File "/usr/lib/python3.4/multiprocessing/popen_fork.py", line 69, in _launch
   parent_r, child_w = os.pipe()
 OSError: [Errno 24] Too many open files

我在多处理方面相当新(我把https://docs.python.org/2/library/multiprocessing.html#multiprocessing.Process作为此代码的基础)并且我不理解这个输出。似乎进程的创建是好的,但不是开始。

如果您有任何建议,我将非常感激!

汤姆

0 个答案:

没有答案