- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
concurrent.futures.ThreadPoolExecutor
的文档说:
Changed in version 3.5: If max_workers is
None
or not given, it will default to the number of processors on the machine, multiplied by5
, assuming that ThreadPoolExecutor is often used to overlap I/O instead of CPU work and the number of workers should be higher than the number of workers for ProcessPoolExecutor.
max_workers
值取决于 CPU 的数量。不管我有多少 CPU,在任何时间点都只能运行一个 Python 线程。
max_workers
根据CPU数量决定?
最佳答案
检查处理器数量比检查程序的 I/O 限制要容易得多,尤其是在线程池启动时,当您的程序还没有真正开始工作时。没有什么比默认值更好的了。
此外,添加默认值是一个漂亮的 low-effort , low-discussion改变。 (以前,没有默认值。)尝试变得花哨会是更多的工作。
也就是说,变得更狂热可能会有所返回。也许是某种根据负载调整线程数的动态系统,因此您不必在信息最少的时候决定计数。不过,除非有人写,否则它不会发生。
关于python - 为什么 ThreadPoolExecutor 的默认 max_workers 是根据 CPU 数量决定的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56195679/
根据documentation ThreadPoolExecutor 的 If max_workers is None or not given, it will default to the num
我在网上找了好久。但没有用。请帮助或尝试给我一些如何实现这一目标的想法。 当我使用python模块concurrent.futures.ThreadPoolExecutor(max_workers=N
使用 python grpc 服务器时, server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) 这是实例化 grpc 服务器
concurrent.futures.ThreadPoolExecutor 的文档说: Changed in version 3.5: If max_workers is None or not gi
在从 concurrent.futures 中决定将 max_workers 设置为什么时,需要考虑哪些因素? 只要您期望 Python 3.5+ 可用,是否有任何理由不将 max_workers 设
我是一名优秀的程序员,十分优秀!