TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Linear Exeuction, Multiprocessing, and Multithreading IO-Bound Tasks in Python

10 点作者 zacjszewczyk超过 5 年前

3 条评论

ebg13超过 5 年前
Whenever I see a blog post on Python concurrency that recommends something other than concurrent.futures ThreadPoolExecutor or ProcessPoolExecutor, I shake my head in disappointment at how far we've strayed from "one obviously right way". Why in 2020 am I seeing someone manually close and join a worker pool (blocking!) to return all results all at once because they rewrote executor.map using multiprocessing? Why do they del pool immediately before returning instead of just letting it run out of scope? Why are they using map, which orders the result, if they just want to call all? If performance matters, you want to read the results in the order of completion not the order of submission, and you don't want to wait for all of them to complete if any of them fail. Where did Python's "right way" go sideways?
评论 #22149114 未加载
Brotkrumen超过 5 年前
&gt;First, terms. Most programs work from top to bottom. The next line runs after the last one finishes. We call these linear<p>Sequential is the term you&#x27;re looking for.
评论 #22148976 未加载
jwandborg超过 5 年前
I&#x27;m 99% sure threads will run on all cores. I think the author has confused multithreading with hyperthreading.
评论 #22148906 未加载
评论 #22148920 未加载