[Twisted-Python] Question about XMLRPC, Sync and ASync

Andrew Francis andrewfr_ice at yahoo.com
Sat Aug 7 14:36:02 EDT 2010

Hi Colin:

> Message: 1
> Date: Fri, 06 Aug 2010 11:02:33 -0700
> From: Colin Fox <greenenergy at gmail.com>
> Subject: [Twisted-Python] Question about XMLRPC, Sync and
> ASync
> To: twisted-python at twistedmatrix.com
> Message-ID: <4C5C4E39.6080807 at gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1

> What I'm trying to do now has me a little stumped -- I have
> two servers, one of which answers XMLRPC requests, and it calls another
> one using the twisted basic.LineReceiver system.

I am a little confused about the basic.LineReceiver because I thought
that was used for creating server protocols?

> So I have an incoming XMLRPC request, and I need to issue a
> command to the other server and wait for it to come back before I
> respond to the xmlrpc call. So I'm trying to do an async call inside a
> synchronous call.

I'm a bit rusty but lets use this simple example of a XMLRPC server
making another XMLRPC request, processing the data and returning it:

class MyXMLRpcServer(xmlrpc.XMLRPC):
    def __init__(self):
        self.service = xmlrpc.Proxy("http://www.dude.com")

    def xmlrpc_someFunction(self, *argv, **kwargs):
        return self.service.callRemote(someFunction).\

self.service.callRemote returns a deferred. Returning a deferred
tells the reactor that someFunction() is not finished processing and
to call processResult when there is data from www.dude.com 

eventually processResult(data) is called

def processResult(data)
    do something with data
    return result

This should return a result to the XMLRPC client.



More information about the Twisted-Python mailing list