SHARE
TWEET

Kevin

a guest Apr 13th, 2010 155 Never
  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
RAW Paste Data
Top