문제

I'm currently trying to use pool multiprocessing function in order to calculate multiple part of tables at the same time. My code is basically:

def funtion(tab1,tab2,...)
  ...

def function_wrapper(args):
  return function(*args)

pool = Pool(processes=num_thread)
arg = [(table1(i,:),table2(i,:),...)for i in range(1000)]
pool.map(function_wrapper, arg)
pool.close()
pool.join() 

And I get the error: IndexError: too many indices .

Is someone can help me to write correctly this? Thanks.

도움이 되었습니까?

해결책

table1(i,:) should have raised a SyntaxError. funtion should probably be function. Please modify the code below so that we have runnable code which exhibits the IndexError. Otherwise, as you can see below, there is no error in the code you posted.

import multiprocessing as mp
def function(tab1,tab2):
    return tab1+tab2

def function_wrapper(args):
    return function(*args)

if __name__ == '__main__':
    pool = mp.Pool()
    arg = [(i,i) for i in range(1000)]
    print(pool.map(function_wrapper, arg))
    pool.close()
    pool.join() 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top