如果我用max worker初始化这个类,如下所示: with ThreadPoolExecutor(max_workers=20) as executor: 那么我可以只提交我想要的线程数吗?假设是1k? for n in range(1000):
threads.append(executor.submit(some_function, n)) 它仍然会在一个线程中保持最多20个线程?我只是想知道如何管理一些长度为X的数据堆栈的执行,而不是N个线程的多线程代码。
那么ProcessPoolExecutor呢,他的行为是一样的吗?def func(task):executor = ThreadPoolExecutorwait=True) # ok, here the main thread waits for others
executor = ThreadPoolExecutor</em
我无法理解的是,尽管ThreadPoolExecutor使用守护进程工作人员,但即使主线程退出,它们仍然会运行。我可以在python3.6.4中提供一个最小的示例:import time
while True:但是实际上,即使工作线程是守护进程线程,它仍然在运行。ThreadPoolExecutor的源代码确认工作