Something like asynchronous XML-RPC possible?

"Martin v. Löwis" martin at v.loewis.de
Fri Jan 24 06:40:22 EST 2003


Will Stuyvesant wrote:
> Under the hood the processes communicate by means of TCP.  But now my
> boss wants them to communicate by means of UDP!  Any ideas how to
> accomplish this?  It would mean that operation or method calls are no
> longer possible, only communication via events will be there.  

Not necessarily: you can implement synchronous communication on top of 
UDP as well (just as you can implement asynchronous methods on top of TCP).

> The desired usage pattern would be::
> 
>   p2 = remote_async_process(url, portnumber)
>   p2.sendEvent(event)

Traditionally, the usage pattern would be different:

p2 = remote_async_process(url, portnumber)
request = p2.method(params)
while not request.done():
   do_other_stuff()
result = request.result()

(of course, the request object can be discarded if no result is expected)

BTW, the same usage pattern is possible over TCP, as well, even without 
cooperation from the server.

> If you know a solution please let me know.  Especially if the solution
> only uses standard Python libraries.  I think it could be done using
> just xmlrpclib and SimpleHTTPServer with a UDP request handler or
> something, but its usage patterns are confusing me and if you have
> done this already please let me know!

But you have already outlined a solution! This is certainly all possible 
in plain Python, using existing libraries. What part is confusing to 
you? Just try to implement this step-by-step, starting with how you 
would implement your sendEvent function (traditionally, the client side 
is easier to implement than the server side).

However, I would question that using XML-RPC on top of http is useful, 
since you are inventing a proprietary protocol, anyway: You could just 
as well send plain strings, or pickles.

Regards,
Martin






More information about the Python-list mailing list