HubSpot/hapipy — pull request #1 by bbeaudreault (2011-10-22 20:55:35+00:00)
Title: Add PyCurl support for threaded api calls

For applications doing many api calls, it sort of sucks to have to do them in sequence.

Added a mixins directory, and created a PyCurlMixin. This can be enabled by calling a new mixin() function, which I added to BaseClient. It maintains a queue of API calls and executes them in parallel in libcurl when process_queue() is called. Process_queue() returns a list of data, in the order of your API calls. Any server-side issues will be denoted by the addition of an 'exception' key in the dictionary item of the API call that failed.

I made modifications to base.py to make it more easily extensible, by breaking up the helper functions into more atomic pieces. PyCurlMixin overrides the _call function to capture client calls for later processing.

Added a test to test_nurturing that doesn't necessarily ensure the requests happen in parallel, but tests that the workflow works.