Something like asynchronous XML-RPC possible?

Will Stuyvesant hwlgw at hotmail.com
Fri Jan 24 15:35:00 CET 2003


[Martin v. Löwis]
> 
> Not necessarily: you can implement synchronous communication on top of 
> UDP as well (just as you can implement asynchronous methods on top of TCP).
> 

Thank you for your response, and I agree with you.  But see my other
response (to Irmen de Jong) as to why I need UDP.  Has to do with a
real-life protocol, called "dowhatisay".

> 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()
> 

I have already implemented usage patterns like this one, simulating
asynchronous communication with synchronous communication.  Among
others there is one that spawns a thread that catches the return
value.  That one I also use for combining listening for synchronously
implemented XMLRPC operation calls with Tkinter.  But all that is not
good enough.  The usage pattern I have to give is::

  r = remote_process(url, port, ...)
  r.sendEvent(event)

where ``event`` preferably is allowed to be an instance object of some
Event class.

> 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.
> 

Well I just do not understand how to use the UDPRequestHandler (or
something like that) and HTTPServer(protocol = "UDP") and registering
an instance object with it so its "methods" act like event handlers
(caller not blocking and no return value send back to caller).  I did
not find much examples in the docs, and the examples I found were all
about TCP.  There is one example called "Heartbeat" that does UDP but
I would have to rewrite the "requesthandler" and to provide a
registering mechanism like SimpleXMLRPCServer has.  Uh oh.  This just
gets over my head.  Am I making sense here? :)


server software something could be something like::

 class MyRemoteComponent:  # just an example class
     def sendEvent(self, event):
         print event, "received!"    # only visible serverside

 class XMLRPCviaUDP( fooRequestHandler, barHTTPServer ) :
     def __init__(self, url, port): 
         print "???"
     def register(self, instanceObject):
         print "I am serving the methods of instanceObj as event
handlers",
         print "I am not going to give back results."

 x = XMLRPCviaUDP("http://myhost.com/~mylogin", 10000)
 r = MyRemoteComponent()
 x.register(r)

or maybe pass r in the constructor of XMLRPCviaUDP.  Not having to
import any libraries that do not come with the default python 1.5.2
installation would be great.  I have the feeling its possible.  Its
just that at this point I do not understand the python libraries that
could be used well enough to do it.  So meanwhile I will spend some
time reading their sourcecode if I can find it.

client software something like outlined earlier.  The thing to write
here of course is the "remote_process" function.

So its a coding contest now.  Any help would be greatly appreciated!




More information about the Python-list mailing list