Created
January 18, 2011 07:16
-
-
Save masahitojp/784084 to your computer and use it in GitHub Desktop.
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
import socket | |
from multiprocessing import Pool,Process | |
def get(url): | |
job =socket.gethostbyname(url) | |
return job | |
if __name__ == '__main__': | |
urls= ['www.google.com', 'www.yahoo.com', 'www.python.org'] | |
pool = Pool(processes =5) | |
for url in urls: | |
result = pool.apply_async(get, [url]) | |
print result.get(timeout=10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment