error in SimpleXMLRPCServer

vaibhav pol vaibhav4947 at gmail.com
Mon Jul 7 08:10:51 CEST 2008


hi,
   I create a SimpleXMLRPCServer script which execute the command on server
and return the result.
 code is below



accessList=(
   'test.org'
    )




class Server(SimpleXMLRPCServer.SimpleXMLRPCServer):
    def __init__(self,*args):

SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self,(args[0],args[1]))

    def server_bind(self):
                self.socket.setsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR, 1)
                SimpleXMLRPCServer.SimpleXMLRPCServer.server_bind(self)


    def verify_request(self,request, client_address):
        if client_address[0] in accessList:
            return 1
        else:
            return 0

class xmlrpc_registers:
    def __init__(self):
        self.python_string = string

    def clientfun(self,argument):
        try:
               cmd = argument
               (stdin,stdout,stderr)=popen3(cmd)
               stdin.close()
               value2=stdout.read()
               value3=stderr.read()
               stdout.close()
               stderr.close()
               output = {"stdout":value2,"stderr": value3}
               return output


if __name__ == "__main__":
        if (len(sys.argv) == 3):
            try :
                    servername=sys.argv[1]
                    portnumber=int(sys.argv[2])
                    server = Server(servername,portnumber)
                    server.register_instance(xmlrpc_registers())
                    server.serve_forever()
            except Exception,e:
                    print "Root service  is shutting down .."
                    print str(e)
        else:
           print "Please provide <\"hostname or ip\"> <\"portnumber\">"


this server side code i run in background using nohup
from client when i  call function it execute fine but after some time when i
call it gives following error


<ProtocolError for hostname:portnumber /RPC2: -1 >

and server program killed.



please help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080707/490d6780/attachment.html>


More information about the Python-list mailing list