469,964 Members | 1,717 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 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.


================================================== ==================

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
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))
Jul 18 '05 #1
0 1107

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
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.