Here's an example of a threaded XMLRPC server using SimpleXMLRPCServer. Note the wx.CallAfter to call into the wx main thread and the "return 0" (though you can configure the server so that return values of None are OK.)
from SimpleXMLRPCServer import SimpleXMLRPCServer
import threading
class XMLRPCServerThread(threading.Thread):
def __init__(self, remoteObject, host='localhost', port=8000):
self.remoteObject = remoteObject
self.host = host
self.port = port
threading.Thread.__init__(self)
def stop(self):
self.server.shutdown()
def run(self):
self.server = SimpleXMLRPCServer( (self.host, self.port), logRequests=False )
self.server.register_instance( self.remoteObject )
self.server.serve_forever()
class MyRemoteCalls(object):
def __init__(self, obj):
self.obj = obj
def exampleCall(self, arg):
wx.CallAfter(self.obj.method, arg)
return 0
def getRPCThread(obj, host='localhost', port=8000):
remoteObj = MyRemoteCalls(obj)
rpcThread = XMLRPCServerThread(remoteObj, host, port)
rpcThread.start()
return rpcThread
wx.CallAfterwhen trying to update the GUI from the new thread.