在从 concurrent.futures 中决定将 max_workers 设置为什么时,需要考虑哪些因素?
只要您期望 Python 3.5+ 可用,是否有任何理由不将 max_workers 设置为 None ,这将“默认为机器上的处理器数量,乘以 5”,如此处文档中所述? https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor
最佳答案
我不认为这个问题可以如此普遍地解决;这将取决于每个案例。
来自 this answer :
The more threads you use, the higher concurrency you'll achieve (up to a point), but the less CPU cycles you'll get (as there will be context switches). You have to instrument your application under typical workloads to see what works best for you. There is no universally optimal solution for this.
关于python - 从 concurrent.futures 使用 ThreadPoolExecutor 时的 max_workers 数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47498288/