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

SimpleXMLRPCServer

P: n/a
Hi,
the typical usage of SimpleXMLRPCServer registers some
class with the server instance and then jumps into a
serve-forever loop, e.g.

server = SimpleXMLRPCServer(('', 8000))
server.register_instance(MyClass())
server.serve_forever()

is there a way to process actions other than XML-RPC
requests using SimpleXMLRPCServer? Is is possible to do
something like

server = SimpleXMLRPCServer(('', 8000))
server.register_instance(MyClass())
while(1)
if(checkSomeCondidion()):
server.serve_once()
else: server.stop()

thanks,
max
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Maxim> is there a way to process actions other than XML-RPC requests
Maxim> using SimpleXMLRPCServer? Is is possible to do something like

Maxim> server = SimpleXMLRPCServer(('', 8000))
Maxim> server.register_instance(MyClass())
Maxim> while(1)
Maxim> if(checkSomeCondidion()):
Maxim> server.serve_once()
Maxim> else: server.stop()

You should be able to override the serve_forever() method.

Skip

Jul 18 '05 #2

P: n/a
Here is an example of a server which runs as long as self.running
is set:

class SimpleXMLRPCServer_with_stop(SimpleXMLRPCServer.Si mpleXMLRPCServer):

def __init__(self, *args, **kwds):
self.running = True
SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(sel f, *args, **kwds)

def serve_while_running_is_set(self):
"""Server while running is set."""
while self.running:
self.handle_request()

Skip Montanaro wrote:
Maxim> is there a way to process actions other than XML-RPC requests
Maxim> using SimpleXMLRPCServer? Is is possible to do something like

Maxim> server = SimpleXMLRPCServer(('', 8000))
Maxim> server.register_instance(MyClass())
Maxim> while(1)
Maxim> if(checkSomeCondidion()):
Maxim> server.serve_once()
Maxim> else: server.stop()

You should be able to override the serve_forever() method.

Skip


Jul 18 '05 #3

P: n/a
Bernhard Mulder wrote:
Here is an example of a server which runs as long as self.running
is set:

class SimpleXMLRPCServer_with_stop(SimpleXMLRPCServer.Si mpleXMLRPCServer):

def __init__(self, *args, **kwds):
self.running = True
SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(sel f, *args, **kwds)

def serve_while_running_is_set(self):
"""Server while running is set."""
while self.running:
self.handle_request()

So putting it in my original terms this would be:

server = SimpleXMLRPCServer(('', 8000))
server.register_instance(MyClass())
while(1)
if(checkSomeCondidion()):
server.handle_request()
else: server.stop()

?
thanks.
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.