how to make a SimpleXMLRPCServer abort at CTRL-C under windows

Gabriel Genellina gagsl-py2 at
Sat Feb 6 01:56:21 CET 2010

En Fri, 05 Feb 2010 20:03:51 -0300, News123 <news123 at> escribió:

> I'm using an XMLRPC server under Windows.
> What I wonder is how I could create a server, that can be killed with  
> The server aborts easily with CTRL-BREAK but not with CTRL-C (under  
> Windows)
> If I press CTRL-C it will only abort when the next RPC call occurs.
> It seems it is blocking in the select() call in the handle_request()
> function.

Python 2.6 and up behaves exactly as you want.
On previous versions you may use this:

class MyXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):

     ... your methods ...

     if not hasattr(SimpleXMLRPCServer.SimpleXMLRPCServer, 'shutdown'):

         # pre 2.6
         quit = False

         def serve_forever(self):
             while not self.quit:

         def shutdown(self):
             self.quit = True

         def server_bind(self):

Gabriel Genellina

More information about the Python-list mailing list