【发布时间】:2019-06-12 11:56:25
【问题描述】:
我想将不同的参数传递给 ThreadPool.apply_async() 方法。我该怎么做?我以为是通过以下方式完成的,但我错了。 我可以改用 Thread 吗? 提前谢谢你
#!/usr/bin/env python
import multiprocessing
def testMethod(arg1, arg2, arg3):
print(f"{arg1} - {arg2} - {arg3}"
if __name__ == '__main__':
pool = multiprocessing.Pool()
for t in range(1000):
pool.apply_async(testMethod, t, arg2, arg3)
【问题讨论】:
标签: python multithreading arguments threadpool pool