Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1953

Show
Ignore:
Timestamp:
04/26/08 19:31:35
Author:
fumanchu
Message:

Fix for #757 (Reduce socket timeout for wait_for_free_port to speed up startup).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/process/servers.py

    r1938 r1953  
    164164    return server_host 
    165165 
    166 def check_port(host, port): 
     166def check_port(host, port, timeout=1.0): 
    167167    """Raise an error if the given port is not free on the given host.""" 
    168168    if not host: 
     
    181181            # See http://groups.google.com/group/cherrypy-users/ 
    182182            #        browse_frm/thread/bbfe5eb39c904fe0 
    183             s.settimeout(1.0
     183            s.settimeout(timeout
    184184            s.connect((host, port)) 
    185185            s.close() 
     
    198198    for trial in xrange(50): 
    199199        try: 
    200             check_port(host, port) 
     200            # we are expecting a free port, so reduce the timeout 
     201            check_port(host, port, timeout=0.1) 
    201202        except IOError: 
    202203            # Give the old server thread time to free the port. 
    203             time.sleep(.1) 
     204            time.sleep(0.1) 
    204205        else: 
    205206            return 

Hosted by WebFaction

Log in as guest/cpguest to create tickets