gumuz at looze.net
Fri Dec 5 17:13:07 CET 2003
Below this message you can see my code. It is a modified version of the
twisted xml-rpc server examples. I am trying to figure out how to implement
non-blocking methods. I found out that I have to use 'defer' to do that, but
I have no clue how to do this. Unfortunately the documentation could not
make this clear to(unless I am missing some docs). I have already added a
function called xmlrpc_block to represent a actual 'blocking function'.
I hope someone can show me how to modify this so the server does not block
any other clients when xmlrpc_block is called.
from twisted.web import xmlrpc, server
from twisted.internet import reactor
"""An example object to be published."""
def xmlrpc_echo(self, x):
"""Return all passed args."""
def xmlrpc_block(self, duration=10):
"""block the instance for a specified duration"""
return "i slept %s seconds!" % (str(duration))
# this only runs if the module was *not* imported
if __name__ == '__main__':
r = Example()
More information about the Python-list