Fix User-Agent for the xmlrpc.client, and catch KeyboardInterrupt for the standalone xmlrpc.server.

This commit is contained in:
Florent Xicluna 2011-10-30 20:39:24 +01:00
parent 2b6403e5d1
commit 75861df9ab
3 changed files with 14 additions and 5 deletions

View file

@ -956,8 +956,13 @@ class DocCGIXMLRPCRequestHandler( CGIXMLRPCRequestHandler,
if __name__ == '__main__':
print('Running XML-RPC server on port 8000')
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_function(pow)
server.register_function(lambda x,y: x+y, 'add')
server.serve_forever()
print('Serving XML-RPC on localhost port 8000')
try:
server.serve_forever()
except KeyboardInterrupt:
print("\nKeyboard interrupt received, exiting.")
server.server_close()
sys.exit(0)