[Twisted-web] xmlrpc and deferred result doubts

Thomas HERVE therve at free.fr
Mon Feb 6 01:33:54 MST 2006

Quoting Gustavo Rahal <gustavo at grahal.net>:

> Hi All
> I have a doubt about how to factor the an xmlrpc server code.
> Basicly what happens is:
> def xmlrpc_runCmd(self, hostname, command):
>    # I call a method that returns a deferred and because of that I
>    # don't have anything to return to the xmlrpc client.
>    runComm = conn.runCommand(hostname, command)
>    # the line below doesn't make much sense because the output needs to
>    # return to the xmlrpc client
>    runComm.addCallback(self.printOutput)
>    return ???? # return what?!?!?!?
> What should I do? How should I factor the code?

As JP told you, you should return the deferred 'runComm' without adding the
callback 'self.printOutput'. The method render of XMLRPC automatically add the
'_cbRender' callback which does the job, and return the code 'NOT_DONE_YET'
which makes you client wait.


More information about the Twisted-web mailing list