We're developing client-server XML-RPC based application. Server part should know IP address of each client on per request basis.
To accomplish this we mix SocketServer.ThreadingMixIn into SimpleXMLRPCServer and subclass SimpleXMLRPCRequestHandler to redefine it's _dispatch method. Below is the code:
class ThreadedXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
pass
class RequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
def _dispatch(self, method, params):
function = self.server.funcs[method]
def decor(function, ip_addr):
def new_function(*args):
try:
return function(ip_addr, *args)
except Exception, err:
log_msg('Exception ocurred in XMLRPC thread (%s)!' % err)
return new_function
return decor(function, self.client_address[0])(*params)
The problem is that sometimes request IP addresses and request data are all processed mixed up, i. e. request IP address doesn't match it's real address.
Is there some problem with the last line of _dispatch or do we miss something?
Thanks!