Basicly I want to run my xmlrpc server in separate thread or together with my other code, however, after server.serve_forever()
there's no way that I can get my another code running after this function. seem server.serve_forever()
is running forever there.
self.LocalServer = SimpleThreadedXMLRPCServer(("localhost",10007))
self.LocalServer.register_function(getTextA) #just return a string
self.LocalServer.serve_forever()
print "I want to continue my code after this..."
.... another code after this should running together with the server
I tried the multithreading concept but still no luck here. Basicaly I want to run the xmlrpc server together with the rest of my code.
Thank you for your kind of help.
You could create a ServerThread
class to encapsulate your XML-RPC server and run it in a thread :
class ServerThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.localServer = SimpleThreadedXMLRPCServer(("localhost",10007))
self.localServer.register_function(getTextA) #just return a string
def run(self):
self.localServer.serve_forever()
You can use this class the following way :
server = ServerThread()
server.start() # The server is now running
print "I want to continue my code after this..."