Hi Colin: > Message: 1 > Date: Fri, 06 Aug 2010 11:02:33 -0700 > From: Colin Fox <greenene...@gmail.com> > Subject: [Twisted-Python] Question about XMLRPC, Sync and > ASync > To: twisted-python@twistedmatrix.com > Message-ID: <4c5c4e39.6080...@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).\ addCallback(processResult) 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. Cheers, Andrew _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python