Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li>Receive xmlrpc request. Compute request id if you need it to make request to the "binary" server. Do not return from the method</li> <li>Make asynchronous request to the "binary" server (you are client) in the same method. Do not return yet</li> <li>Drop this step (the xmlrpc request is not complete yet, nothing to poll)</li> <li>Return a deferred "real result". You are done. xmlrpc machinery will return real result when it is ready to the xmlrpc client</li> </ol> <p>Here's an example xmlrpc server that returns a deferred subprocess output:</p> <pre><code>#!/usr/bin/env python from timeit import default_timer as timer from twisted.internet import reactor, utils from twisted.web import xmlrpc, server class Example(xmlrpc.XMLRPC): def xmlrpc_echo(self, x): """Sanity check.""" return x def xmlrpc_getoutput(self): shell_command = "echo before sleep; sleep 10; echo after sleep" start = timer() d = utils.getProcessOutput("/bin/sh", ["-c", shell_command]) print("Deferred created in %.2f seconds" % (timer() - start,)) # instant return d reactor.listenTCP(9657, server.Site(Example())) reactor.run() </code></pre> <p>And the corresponding xmlrpc client:</p> <pre><code>#!/usr/bin/env python from timeit import default_timer as timer import xmlrpclib s = xmlrpclib.Server('http://localhost:9657/') def report_delay(func, *args): start = timer() print("Result %r took us %.2f seconds" % (func(*args), timer() - start)) report_delay(s.echo, "Mor-ee-air-teeeee") # should be instant report_delay(s.getoutput) # should be ~10 seconds </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload