import requests from multiprocessing.pool import ThreadPool %time r = requests.get("http://localhost:8888/10") r.content def get_data(ID): """function for getting data from our slow server""" r = requests.get("http://localhost:8888/%i" % ID) return int(r.content) IDs = range(128) for nthreads in [1, 2, 4, 8, 16, 32]: pool = ThreadPool(nthreads) tic = time.time() result = pool.map(get_data, IDs) toc = time.time() print "%i threads: %3.1f seconds" % (nthreads, toc-tic)