Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Kevin

By: a guest on Apr 13th, 2010  |  syntax: Python  |  size: 0.37 KB  |  views: 146  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. servers = ["google.com", "stackoverflow.com", "yahoo.com"]
  2. results = []
  3.  
  4. def worker(server):
  5.   host = server[0]
  6.   # connect to host and such
  7.   return result
  8.  
  9. def finish(worker, result):
  10.   results.append(result)
  11.  
  12. pool = ThreadPool(1000)
  13. item = makeRequests(worker, servers, finish)
  14. [pool.putRequest(req) for req in requests]
  15. pool.wait()
  16.  
  17. # do something with results