Python Twisted multiple clients error in factory/protocol -


i getting error "exceptions.attributeerror: myserverfactory instance has no attribute 'isleaf'"

my code below, working single client connection, tried making changes multiple clients fails.

#!/usr/bin/python import sys ###### autogeneration please not write new imports above line ######### twisted.web import xmlrpc, server import twisted twisted.internet.protocol import protocol, factory twisted.internet import reactor  port = 2222 server_info = 'testing concurrency' class twiestedserver(xmlrpc.xmlrpc, protocol):     """     example of using own policy fetch handler     """     """     =======================================================     function name : __init__     purpose       : initialize libraries , add functions     inputs        : self                     args                     kwargs     outputs       : none     =======================================================     """     def __init__(self,factory):         xmlrpc.xmlrpc.__init__(self)         # init libraries          self._proceduretocallable = {}         self.factory = factory          # add functions         self._proceduretocallable = {             'get_server_info':      self.get_server_info,         }      """     =======================================================     function name : __dir__     purpose       :      inputs        : self     outputs       : none     =======================================================     """     def __dir__(self):         dir_list1 = [k k in self.__dict__]         dir_list2 = [k k in self._proceduretocallable]         dir_list = dir_list1 + dir_list2         return dir_list      def fio(self,x):         if x == 1 or x == 2:            return 1     else:         return self.fio(x-1) + self.fio (x-2)      """     =======================================================     function name : get_server_info     purpose       : information server     inputs        : self     outputs       : none     =======================================================     """     def get_server_info(self,x):          return self.fio(x)         #return server_info      """     =======================================================     function name : lookupprocedure     purpose       : check if proceedure has called                     available in class     inputs        : self                     procedurepath     outputs       : none     =======================================================     """     def lookupprocedure(self, procedurepath):         try:             return self._proceduretocallable[procedurepath]         except keyerror, e:             raise xmlrpc.nosuchfunction(self.not_found,                         "procedure %s not found" % procedurepath)      """     =======================================================     function name : direct_server_method     purpose       : display 1 present on server                     library     inputs        : self     outputs       : none     =======================================================     """     def direct_server_method(self):         return "i direct on server library"      """     =======================================================     function name : listprocedures     purpose       :      inputs        : self     outputs       : none     =======================================================     """     def listprocedures(self):         """         since override lookupprocedure, suggested override         listprocedures too.         """          return self.__dir__()     """     =======================================================     function name : _ebrender     purpose       : throw error     inputs        : self                     failure     outputs       : failure value     =======================================================     """     def _ebrender(self, failure):          #if isinstance(failure.value, xmlrpc.fault):         #    return failure.value         return xmlrpc.fault(str(failure), "error")  class myserverfactory(factory):     def buildprotocol(self, addr):         return twiestedserver(self)  if __name__ == '__main__':     try:         twisted.internet import reactor, protocol         r = myserverfactory()         reactor.listentcp(port, server.site(r))         reactor.run()     except twisted.internet.error.cannotlistenerror e:         sys.stderr.write(str(e))         sys.exit(98) 

we've used fio function test concurrency of clients fio(40) takes around 2-3 mins, meanwhile server should resolve fio(3).

thanks in advance.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -