Asynchronous XML-RPC
As part of converting Hep to use the Twisted Framework, I had to find a way to do XML-RPC calls asynchronously. This is to avoid having Hep freeze up while waiting to for an XML-RPC reply to come back from a server.
The result was asyncxmlrpc.py, which you can find here. It provides a ServerProxy class that works just like the one in Python’s built-in xmlrpclib, except that when you call a function it returns a Twisted Deferred object that you can add callbacks too.
Example:
from twisted.internet import reactor
def printState(stateName):
print stateName
import asyncxmlrpc
s = asyncxmlrpc.ServerProxy('http://betty.userland.com')
d = s.examples.getStateName(19)
d.addCallback(printState)
reactor.run()
At the moment this only works over straight HTTP, no SSL. And of course, it requires Twisted to work.