By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,732 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,732 IT Pros & Developers. It's quick & easy.

xml-rpc/twisted question

P: n/a
Hi all,

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.

thanx,
Guyon

================================================== ==================
#TestServer.py

from twisted.web import xmlrpc, server
from twisted.internet import reactor

class Example(xmlrpc.XMLRPC):
"""An example object to be published."""

def xmlrpc_echo(self, x):
"""Return all passed args."""
return x

def xmlrpc_block(self, duration=10):
"""block the instance for a specified duration"""
import time
time.sleep(duration)
return "i slept %s seconds!" % (str(duration))
# this only runs if the module was *not* imported
if __name__ == '__main__':
r = Example()
reactor.listenTCP(7080, server.Site(r))
reactor.run()
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.