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

Changeset 1871

Show
Ignore:
Timestamp:
01/19/08 20:38:29
Author:
fumanchu
Message:

New wsgiserver.socket_errors_nonblocking, plus a new plat_specific_errors function to help generate it and socket_errors_to_ignore.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/wsgiserver/__init__.py

    r1867 r1871  
    6666 
    6767import errno 
    68 socket_errors_to_ignore = [] 
    69 # Not all of these names will be defined for every platform. 
    70 for _ in ("EPIPE", "ETIMEDOUT", "ECONNREFUSED", "ECONNRESET", 
    71           "EHOSTDOWN", "EHOSTUNREACH", 
    72           "WSAECONNABORTED", "WSAECONNREFUSED", "WSAECONNRESET", 
    73           "WSAENETRESET", "WSAETIMEDOUT"): 
    74     if _ in dir(errno): 
    75         socket_errors_to_ignore.append(getattr(errno, _)) 
    76 # de-dupe the list 
    77 socket_errors_to_ignore = dict.fromkeys(socket_errors_to_ignore).keys() 
     68 
     69def plat_specific_errors(*errnames): 
     70    """Return error numbers for all errors in errnames on this platform. 
     71     
     72    The 'errno' module contains different global constants depending on 
     73    the specific platform (OS). This function will return the list of 
     74    numeric values for a given list of potential names. 
     75    """ 
     76    errno_names = dir(errno) 
     77    nums = [getattr(errno, k) for k in errnames if k in errno_names] 
     78    # de-dupe the list 
     79    return dict.fromkeys(nums).keys() 
     80 
     81socket_errors_to_ignore = plat_specific_errors( 
     82    "EPIPE", "ETIMEDOUT", "ECONNREFUSED", "ECONNRESET", 
     83    "EHOSTDOWN", "EHOSTUNREACH", 
     84    "WSAECONNABORTED", "WSAECONNREFUSED", "WSAECONNRESET", 
     85    "WSAENETRESET", "WSAETIMEDOUT") 
    7886socket_errors_to_ignore.append("timed out") 
     87 
     88socket_errors_nonblocking = plat_specific_errors( 
     89    'EAGAIN', 'EWOULDBLOCK', 'WSAEWOULDBLOCK') 
    7990 
    8091comma_separated_headers = ['ACCEPT', 'ACCEPT-CHARSET', 'ACCEPT-ENCODING', 

Hosted by WebFaction

Log in as guest/cpguest to create tickets