Skip to content

Instantly share code, notes, and snippets.

@acdha
Created May 15, 2015 18:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acdha/4acfd7387bee082d1ccf to your computer and use it in GitHub Desktop.
Save acdha/4acfd7387bee082d1ccf to your computer and use it in GitHub Desktop.
Multi-threaded network I/O in Python 2/3
from __future__ import absolute_import, unicode_literals, print_function
from multiprocessing.pool import ThreadPool
import requests
pool = ThreadPool(processes=8)
for response in pool.imap_unordered(requests.get, urls):
print(response.status_code, response.url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment