I am working with Python (IPython & Canopy) and a RESTful content API, on my local machine (Mac).
I have an array of 3000 unique IDs to pull data for from the API and can only call the API with one ID at a time.
I was hoping somehow to make 3 sets of 1000 calls in parallel to speed things up.
What is the best way of doing this?
Thanks in advance for any help!
Without more information about what you are doing in particular, it is hard to say for sure, but a simple threaded approach may make sense.
Assuming you have a simple function that processes a single ID:
You can expand that into a simple function that processes a range of IDs:
and finally, you can fairly easily map sub-ranges onto threads to allow some number of requests to be concurrent:
A full example in an IPython Notebook: http://nbviewer.ipython.org/5732094
If your individual tasks take a more widely varied amount of time, you may want to use a ThreadPool, which will assign jobs one at a time (often slower if individual tasks are very small, but guarantees better balance in heterogenous cases).