Exemplo n.º 1
0
def run_server():
    from xmlrpc.server import SimpleXMLRPCServer
    from xmlrpc.server import SimpleXMLRPCRequestHandler
    server = SimpleXMLRPCServer((my_host, my_port),
                                allow_none=True,
                                logRequests=False)
    server.register_function(delete, 'delete')
    server.register_function(get, 'get')
    server.register_function(put, 'put')
    server.register_function(dump, 'dump')
    server.register_function(lambda: setattr(server, 'running', False), 'stop')
    server.running = True
    while server.running:
        try:
            server.handle_request()
        except BaseException as e:
            traceback.print_exc(file=sys.stdout)
    print("server stopped")
Exemplo n.º 2
0
def run_server(host, port):
    from xmlrpc.server import SimpleXMLRPCServer
    server = SimpleXMLRPCServer((host, port),
                                allow_none=True,
                                logRequests=False)
    server.register_function(delete, 'delete')
    server.register_function(get, 'get')
    server.register_function(put, 'put')
    server.running = True
    while server.running:
        try:
            server.handle_request()
        except KeyboardInterrupt:
            print("Shutting down server")
            sys.exit(0)
        except BaseException as e:
            traceback.print_exc(file=sys.stdout)
    print("server stopped")