Hi Colin:
> Message: 1
> Date: Fri, 06 Aug 2010 11:02:33 -0700
> From: Colin Fox <[email protected]>
> Subject: [Twisted-Python] Question about XMLRPC, Sync and
> ASync
> To: [email protected]
> Message-ID: <[email protected]>
> 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
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python