xmlrpclib

Jeremy Jones zanesdad at bellsouth.net
Tue Aug 31 08:14:13 EDT 2004


Graeme Matthew wrote:

>I was a big vague, I hope this makes more sense.
>
>I am talking about the server end.
>
>I understand that xml-rpc is a request response mechansim (i.e it runs over
>http).
>
>The client and the server will span continents i.e Australia to US, US to
>Australia.
>What I am trying to establish is if the server is asynchronous i.e
>multi-threaded i.e what happens when 2 requests hit the server at once?
>
>i.e Does it handle one request at a time?
>  
>
This is the standard/unmodified behavior of the SimpleXMLRPCServer class.

>i.e Does it start a new thread on each request?
>  
>
You have to write a little code to get it to do that.  Here is an 
example snippet:

class ThreadingXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer, 
SocketServer.ThreadingTCPServer):
    """Threaded XML-RPC server."""

    def __init__(self, addr, 
requestHandler=SimpleXMLRPCServer.SimpleXMLRPCRequestHandler, 
logRequests=1):
        self.funcs = {}
        self.logRequests = logRequests
        self.instance = None
        SocketServer.ThreadingTCPServer.__init__(self, addr, requestHandler)


if __name__ == "__main__":
    #server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000))
    server = ThreadingXMLRPCServer(("", 8000))
    server.register_instance(<insert_some_handler_class_here>())
    #server.register_introspection_functions()
    server.serve_forever()

Whenever a request comes in, it is handled by a "process_request" 
method.  The ThreadingTCPServer has overridden that method so that when 
a request comes in, it will spin off a new thread that executes a 
"process_request_thread" method.  In the above piece of code, each 
incoming request will create a new thread. 

>i.e Does it use a threading pool?
>  
>
You could implement a thread pool if you like.  Just look in the 
SimpleXMLRPCServer.py and SocketServer.py files and see what is going on 
in there, specifically in the SocketServer.py file around the 
ThreadingMixIn class.  You could mimic that, create your own threadpool 
and when a request comes into "process_request", you could just hand it 
off to the thread pool.

>I am trying to find other people who have used it successfully as most of my
>dev work is in python.
>  
>
I'm using it now on a very small scale, but it's working great for me.  
Hope this helps.

Jeremy

>Hope this helps
>
>Cheers
>
>Graeme
>
>
>
>"Roger Binns" <rogerb at rogerbinns.com> wrote in message
>news:2hkd02-v7v.ln1 at home.rogerbinns.com...
>  
>
>>Graeme Matthew wrote:
>>    
>>
>>>Just wanted to know if anyone knows if xmlrpclib is scalable i.e can
>>>handle many / asynchronous calls.
>>>      
>>>
>>You should specify what goal it is you are trying to achieve.  For example
>>it isn't clear if you are talking about the server end or the client
>>end.
>>
>>Additionally you haven't said how far apart the client and server are.
>>(Same machine? Same LAN? Same continent?)
>>
>>xmlrpc is not asynchronous.  It is a request/response model.  Each request
>>gets exactly one response.  There is no method for sending data outside
>>of that.  For example the server end can't send random event messages
>>without the client end polling for them.
>>
>>And what do you mean by handle?  Is that a speed question, a reliability
>>question, a size of data structures question?
>>
>>Lastly the current Python xmlrpc implementation, both client and
>>server end makes one network connection per request/response pair
>>and then closes it.
>>
>>Roger
>>
>>
>>    
>>
>
>
>  
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040831/79303dce/attachment.html>


More information about the Python-list mailing list