xmlrpclib timeouts

Discussion in 'Python' started by p2esp, Mar 2, 2004.

  1. p2esp

    p2esp Guest

    Hello,

    I'm using the xmlrpclib module to contact an XMLRPC
    server that takes a long time to send results back. My
    client timeouts.

    The question is whether there is a way to have an
    xmlrpclib client that never timeouts. I have been
    searching for some code examples on how to do that,
    but I could not find any in the xmlrpclib
    documentation.

    Thanks for any hints.



    __________________________________
    Do you Yahoo!?
    Yahoo! Search - Find what you’re looking for faster
    http://search.yahoo.com
     
    p2esp, Mar 2, 2004
    #1
    1. Advertising

  2. p2esp

    Paul McGuire Guest

    "p2esp" <> wrote in message
    news:...
    > Hello,
    >
    > I'm using the xmlrpclib module to contact an XMLRPC
    > server that takes a long time to send results back. My
    > client timeouts.
    >
    > The question is whether there is a way to have an
    > xmlrpclib client that never timeouts. I have been
    > searching for some code examples on how to do that,
    > but I could not find any in the xmlrpclib
    > documentation.
    >
    > Thanks for any hints.
    >


    "Client that never times out" is not a good idea, generally. Nothing in
    life is certain, but even moreso in distributed systems. Timeouts are there
    to protect you from all kinds of problem conditions (busy server, crashed
    server, etc.). You really don't want your client to be in a position of
    waiting for a response that is never going to come.

    You are better off turning your synchronous "wait forever" client into an
    asynchronous "wait for callback" client. Have your client create a listener
    object, and pass a reference to this object as part of your long-running
    method call. This allows the XMLRPC call to complete, since it is a brief
    submission of work, instead of waiting for the work to complete. When the
    server is finished, it uses the callback object to send the results back to
    the client.

    This does make things more complicated - the server has to save the callback
    object so that it knows who to send the results to. The client is probably
    going to be multithreaded, so that the client isn't blocked while waiting
    for the response (although, given your initial design, this may not bother
    you). AND, the server may have to do some exception recovery (or at least
    logging), if the client has disconnected before it was able to send back
    results.

    Another alternative is the "job ticket" model. In this case, the client
    calls the server just as you have it coded now, but the return value is some
    form of job ticket, or job id. The client then uses this id to periodically
    poll the server to see if the results are ready yet. Once the server
    replies that results are ready, the client uses the job id as the argument
    to a getResults() call on the server. This solution is simpler to code, but
    may have implications for network loading (lots of extra polling messages,
    as clients repeatedly check if their results are ready), and the server has
    to handle the case of clients that disconnect and never pick up their
    laundry, um, that is, results.

    There are a number of good reference books about client/server programming.
    One that I like is "Advanced CORBA Programming with C++" by Henning and
    Vinoski. Although it uses CORBA and C++ as its implementation platform, so
    you'll have to map the examples to Python and XMLRPC, the concepts are much
    the same. And don't be too quick to skip the memory management
    discussions - even though Python does its own memory management (in place of
    C++'s new/delete model), it is easy to have distributed memory leaks between
    client and server. (I have seen a Java memory leak happen this way, even
    though Java uses a garbage collection memory management model too.) Another
    good resource is Douglas Schmidt's set of web pages at Washington Univ of
    St. Louis - see http://www.cs.wustl.edu/~schmidt/patterns.html for some
    distributed system patterns papers.

    Good luck - distributed systems can be nerve-wracking, but they are also
    some of the really cool problems to solve.

    -- Paul
     
    Paul McGuire, Mar 2, 2004
    #2
    1. Advertising

  3. p2esp <> wrote in message news:<>...
    > Hello,
    >
    > I'm using the xmlrpclib module to contact an XMLRPC
    > server that takes a long time to send results back. My
    > client timeouts.
    >
    > The question is whether there is a way to have an
    > xmlrpclib client that never timeouts. I have been
    > searching for some code examples on how to do that,
    > but I could not find any in the xmlrpclib
    > documentation.
    >
    > Thanks for any hints.


    Hmm, I always thought that the XML-RPC client in the xmlrpclib
    module was written already to do exactly that. Ie., it will block
    until it gets a response. There is no timeout functionality within
    it.

    Is the server you are talking to within your own network, or are you
    going through some sort of HTTP proxy either explicitly or
    implicitly, or even some sort of router equipment that does special
    things with HTTP requests. HTTP proxies often have timeouts
    such that if a request takes too long to get back a response, it
    will drop the connection. In other words, the problem may not be
    with the XML-RPC client but some part of the intermediate network.

    Also, what is the XML-RPC server written in? Could it perhaps be
    dropping the connection if the server side code takes too long?
     
    Graham Dumpleton, Mar 3, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmFzb24=?=

    forms authentication timeouts and session timeouts

    =?Utf-8?B?SmFzb24=?=, Jun 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    457
    =?Utf-8?B?SmFzb24=?=
    Jun 22, 2004
  2. Larry
    Replies:
    0
    Views:
    382
    Larry
    Sep 16, 2003
  3. sashan

    xmlrpclib

    sashan, Oct 19, 2003, in forum: Python
    Replies:
    0
    Views:
    447
    sashan
    Oct 19, 2003
  4. Brian Quinlan

    RE: xmlrpclib

    Brian Quinlan, Oct 19, 2003, in forum: Python
    Replies:
    0
    Views:
    392
    Brian Quinlan
    Oct 19, 2003
  5. p2esp

    Re: xmlrpclib timeouts

    p2esp, Mar 2, 2004, in forum: Python
    Replies:
    1
    Views:
    354
    Ross M Karchner
    Mar 2, 2004
Loading...

Share This Page