Changeset 1181


Ignore:
Timestamp:
12/11/06 16:50:14 (6 years ago)
Author:
mglb1
Message:
  • Added extra logging to time how long it takes to render a full request separately from its execution time
  • Add flags and configuration options to turn off SSL for testing purposes
Location:
ccsd/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ccsd/trunk/crcnetd/_utils/ccsd_server.py

    r1151 r1181  
    207207        ccsd_xmlrpc.prof_dir = config_get(None, "profile_dir", \ 
    208208                DEFAULT_PROFILE_DIR) 
     209        use_ssl = config_getboolean(None, "use_ssl", True) 
    209210 
    210211        # Port and logfile 
     
    263264        # Pass off control to Twisted's mainloop 
    264265        threadable.init() 
    265         reactor.listenSSL(port, server.Site(_root, logfile), \ 
    266                 SCF(key, cert, cacert)) 
     266        if use_ssl: 
     267            reactor.listenSSL(port, server.Site(_root, logfile), \ 
     268                    SCF(key, cert, cacert)) 
     269        else: 
     270            reactor.listenTCP(port, server.Site(_root, logfile)) 
    267271        reactor.addSystemEventTrigger("before", "shutdown", shutdownHandler) 
    268272        log_info("Server Started. Ready to serve requests...") 
     
    393397        * Dispatches requests to the appropriate function that was earlier 
    394398          registered via exportViaXMLRPC 
    395         """            
     399        """ 
     400        rstart = time.time() 
    396401        # We import this here to avoid a circular reference 
    397402        from ccsd_session import isSessionValid, getSessionE, \ 
     
    417422                    prof.stop() 
    418423                    prof.close() 
     424                if self.log_times:         
     425                    log_debug("Rendered %s in %0.3f seconds" % \ 
     426                        (func["name"], (time.time()-rstart))) 
    419427                return server.NOT_DONE_YET 
    420428 
     
    428436                    prof.stop() 
    429437                    prof.close() 
     438                if self.log_times:         
     439                    log_debug("Rendered %s in %0.3f seconds" % \ 
     440                        (func["name"], (time.time()-rstart))) 
    430441                return server.NOT_DONE_YET 
    431442             
     
    480491            prof.stop() 
    481492            prof.close() 
     493        if self.log_times: 
     494            log_debug("Rendered %s in %0.3f seconds" % \ 
     495                    (func["name"], (time.time()-rstart))) 
    482496        return server.NOT_DONE_YET 
    483497             
  • ccsd/trunk/scripts/ccsd-console

    r1179 r1181  
    3232# Get hostname, certificates from the commandline 
    3333if len(sys.argv) < 4: 
    34     sys.stderr.write("Usage: %s <server> <key> <cert>\n" %  
     34    sys.stderr.write("Usage: %s [-S] <server> <key> <cert>\n" %  
    3535            sys.argv[0]) 
    3636    sys.exit(1) 
    3737 
     38use_ssl = True 
     39if sys.argv[1] == "-S": 
     40    use_ssl = False 
     41    sys.argv[1:] = sys.argv[2:] 
    3842server = sys.argv[1] 
    3943key = sys.argv[2] 
     
    4448    """XMLRPC Transport to create an HTTPS connection using client certs""" 
    4549 
     50    def __init__(self, use_ssl=True): 
     51        self._use_ssl = use_ssl 
     52 
    4653    def make_connection(self, host): 
    4754        """Overrides the standard make_connection method 
     
    5158         
    5259        host, extra_headers, x509 = self.get_host_info(host) 
    53         try: 
    54             HTTPS = httplib.HTTPS 
    55         except AttributeError: 
    56             raise NotImplementedError( 
    57                 "your version of httplib doesn't support HTTPS" 
    58             ) 
     60        if self._use_ssl: 
     61            try: 
     62                HTTPS = httplib.HTTPS 
     63            except AttributeError: 
     64                raise NotImplementedError( 
     65                        "your version of httplib doesn't support HTTPS" 
     66                    ) 
     67            else: 
     68                return HTTPS(host, None, key_file=key, cert_file=cert); 
    5969        else: 
    60             return HTTPS(host, None, key_file=key, cert_file=cert); 
     70            return httplib.HTTP(host, None) 
    6171 
    6272    def request(self, host, handler, request_body, verbose=0): 
    6373        start = time.time() 
    6474        rv = xmlrpclib.Transport.request(self, host, handler, request_body, verbose) 
    65         end = time.time() 
    66         sys.stdout.write("Request returned in %.4f seconds\n" % (end-start)) 
     75        sys.stdout.write("Request parsed in %.4f seconds\n" % (time.time()-start)) 
    6776        return rv 
    6877 
     
    8796 
    8897# Connect to the server  
    89 s = xmlrpclib.ServerProxy("https://%s/RPC2" % server, MyTransport()) 
     98s = xmlrpclib.ServerProxy("https://%s/RPC2" % server, MyTransport(use_ssl)) 
    9099 
    91100# Query to get the servers version, this acts as a check that a valid  
Note: See TracChangeset for help on using the changeset viewer.