TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Dead easy Python for executing many HTTP requests asynchronously

46 pointsby joshlkover 4 years ago

5 comments

joshlkover 4 years ago
Needed when executing 1 million API requests for example. Use the full force of your machine by utilising async IO via the excellent library Trio.<p>It has been tested in the wild with more than 10 million requests. Automatically handles errors and executes retries.<p>Also provides helper functions for executing embarrassingly parallel async coroutines.
评论 #25060764 未加载
评论 #25067373 未加载
评论 #25066419 未加载
eatonphilover 4 years ago
I&#x27;m curious why one would suggest using this over the built-in ThreadPoolExecutor class?<p>Here&#x27;s a complete, similar example from the Python docs: <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;concurrent.futures.html#threadpoolexecutor-example" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;concurrent.futures.html#th...</a>.<p>Granted that example is more lines of code than the README for this library. But the core of it is fairly straightforward:<p><pre><code> rsps = [] with concurrent.futures.ThreadPoolExecutor(max_workers=N) as executor: futures = [executor.submit(requests.get, url) for url in urls] for future in concurrent.futures.as_completed(futures): rsps.append(future.result)</code></pre>
评论 #25061168 未加载
评论 #25061153 未加载
roywigginsover 4 years ago
Oh, handy. This would have solved the exact problem I had last month (which I solved with just-good-enough fiddling with async python, which I&#x27;m not comfortable in yet)
stevesimmonsover 4 years ago
I have a somewhat related question:<p>What is the current best practice way to parallelize reading many parquet files on S3 using pyarrow? Deep down, it&#x27;s just lots of HTTP requests.
texufover 4 years ago
I&#x27;ve been out of python for a while, why is the package name and the module name different? `install many-requests` vs `import many_requests`
评论 #25064247 未加载