non-blocking XML-RPC

Jeremy Jones zanesdad at bellsouth.net
Mon Oct 25 07:18:00 EDT 2004


Roose wrote:

>Is there a way to make the xmlrpclib calls using ServerProxy not block?
>Basically I am kicking off programs on remote machines, and they take hours
>to run.  I want to use the features of marshaling arguments over, but most
>of the functions will not return any value at all.
>
>Is there some other mechanism I should be using?
>
>thanks,
>Roose
>
>
>  
>

What problem are you trying to solve? 

Do you want any and all XMLRPC requests (or even all requests of a 
certain method) to return back quickly because you don't (want to / have 
to) wait around for them and they don't return anything meaningful 
anyway?  Then you can follow Skip's recommendation of stuffing the 
request into a queue and letting another thread pull things out of the 
queue and spin off a thread to process it.  Or you could use a 
threadpool and have one thread pull requests out of the queue that Skip 
recommended and pass the request to the threadpool.  There's a pretty 
useful threadpool recipe in the online Python Cookbook at 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/203871.  I 
couldn't find it in the dead tree Python Cookbook.  Actually, if you use 
that particular threadpool, you could just have the request handler pass 
the request directly into the threadpool.

Or, do you want to be able to make more than one simultaneous request to 
the XMLRPCServer and not have requests have to wait for each other 
(assuming you're using the SimpleXMLRPCServer with no threaded mix-in)?  
In this case, if it's still unimportant to return anything meaningful to 
the caller, which it appears that it is not, you could still get away 
with using a queue or threadpool.  If you're interested in returning 
something meaningful after computation is completed, then you could look 
into creating a threaded XMLRPCServer using a threading mix-in.  If you 
are interested in this approach, post back and I'll scrounge some sample 
code.

Jeremy Jones



More information about the Python-list mailing list