Pass multiple parameters to concurrent.futures.Executor.map?

后端 未结 6 715
梦毁少年i
梦毁少年i 2020-12-07 17:27

The concurrent.futures.Executor.map takes a variable number of iterables from which the function given is called. How should I call it if I have a generator that pro

6条回答
  •  旧巷少年郎
    2020-12-07 18:00

    I have seen so many answers here, but none of them is as straight forward as using lambda expressions:

    foo(x,y): pass

    want to call above method 10 times, with same value i.e. xVal and yVal? with concurrent.futures.ThreadPoolExecutor() as executor:

    for _ in executor.map( lambda _: foo(xVal, yVal), range(0, 10)):
        pass
    

提交回复
热议问题