Batching HTTP requests with httplib (Python 2.7)

Cameron Simpson cs at zip.com.au
Thu Sep 13 22:31:28 EDT 2012


On 13Sep2012 19:34, Chicken McNuggets <chicken at mcnuggets.com> wrote:
| I'm writing a simple library that communicates with a web service and am 
| wondering if there are any generally well regarded methods for batching 
| HTTP requests?
| 
| The problem with most web services is that they require a list of 
| sequential commands to be executed in a certain order to complete a 
| given task (or at least the one I am using does) so having to manually 
| call each command is a bit of a pain. How would you go about the design 
| of a library to interact with these services?
| 
| Any help is greatly appreciated :).

Maybe I'm missing something. What's hard about:

  - wrapping the web services calls in a simple wrapper which
    composes the call, runs it, and returns the result parts
    This lets you hide all the waffle about the base URL,
    credentials etc in the wrapper and only supply the essentials
    at call time.

  - writing your workflow thing then as a simple function:

      def doit(...):
        web_service_call1(...)
        web_service_call2(...)
        web_service_call3(...)

    with whatever internal control is required?

This has worked for me for simple things.

What am I missing about the larger context?
-- 
Cameron Simpson <cs at zip.com.au>

Clymer's photographs of this procedure show a very clean head. This is a lie.
There is oil in here, and lots of it. - Mike Mitten, rec.moto, 29sep1993



More information about the Python-list mailing list