467,080 Members | 898 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,080 developers. It's quick & easy.

xml-rpc/twisted question

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
  • viewed: 1058
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Robert J Egan | last post: by
6 posts views Thread by yzzzzz | last post: by
reply views Thread by MarionEll | last post: by
reply views Thread by Steve Whitlatch | last post: by
reply views Thread by Stylus Studio | last post: by
5 posts views Thread by laks | last post: by
10 posts views Thread by =?Utf-8?B?YzY3NjIyOA==?= | last post: by
reply views Thread by Jacker | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.