Skip to content

Instantly share code, notes, and snippets.

@masahitojp
Created January 18, 2011 07:16
Show Gist options
  • Save masahitojp/784084 to your computer and use it in GitHub Desktop.
Save masahitojp/784084 to your computer and use it in GitHub Desktop.
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