SimpleXMLRPCServer

Bernhard Mulder bwm at acm.org
Fri Jan 16 18:01:21 CET 2004


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

class SimpleXMLRPCServer_with_stop(SimpleXMLRPCServer.SimpleXMLRPCServer):

    def __init__(self, *args, **kwds):
        self.running = True
        SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self, *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
> 




More information about the Python-list mailing list