Created
May 15, 2015 18:23
-
-
Save acdha/4acfd7387bee082d1ccf to your computer and use it in GitHub Desktop.
Multi-threaded network I/O in Python 2/3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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