Changeset 2230
- Timestamp:
- 04/01/09 11:09:03
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/cherrypy-3.0.x/cherrypy/wsgiserver/__init__.py
r1843 r2230 66 66 67 67 import errno 68 69 socket_error_eintr = plat_specific_errors("EINTR", "WSAEINTR") 70 68 71 socket_errors_to_ignore = [] 69 72 # Not all of these names will be defined for every platform. … … 71 74 "EHOSTDOWN", "EHOSTUNREACH", 72 75 "WSAECONNABORTED", "WSAECONNREFUSED", "WSAECONNRESET", 73 "WSAENETRESET", "WSAETIMEDOUT"): 76 "WSAENETRESET", "WSAETIMEDOUT", "EBADF", "WSAEBADF", 77 "ENOTSOCK", "WSAENOTSOCK"): 74 78 if _ in dir(errno): 75 79 socket_errors_to_ignore.append(getattr(errno, _)) … … 77 81 socket_errors_to_ignore = dict.fromkeys(socket_errors_to_ignore).keys() 78 82 socket_errors_to_ignore.append("timed out") 83 84 socket_errors_nonblocking = plat_specific_errors( 85 'EAGAIN', 'EWOULDBLOCK', 'WSAEWOULDBLOCK') 79 86 80 87 comma_separated_headers = ['ACCEPT', 'ACCEPT-CHARSET', 'ACCEPT-ENCODING', … … 907 914 return 908 915 except socket.error, x: 909 msg = x.args[1] 910 if msg in ("Bad file descriptor", "Socket operation on non-socket"): 916 if x.args[0] in socket_error_eintr: 917 # I *think* this is right. EINTR should occur when a signal 918 # is received during the accept() call; all docs say retry 919 # the call, and I *think* I'm reading it right that Python 920 # will then go ahead and poll for and handle the signal 921 # elsewhere. See http://www.cherrypy.org/ticket/707. 922 return 923 if x.args[0] in socket_errors_nonblocking: 924 # Just try again. See http://www.cherrypy.org/ticket/479. 925 return 926 if x.args[0] in socket_errors_to_ignore: 911 927 # Our socket was closed. 912 return 913 if msg == "Resource temporarily unavailable": 914 # Just try again. See http://www.cherrypy.org/ticket/479. 928 # See http://www.cherrypy.org/ticket/686. 915 929 return 916 930 raise … … 937 951 host, port = sock.getsockname()[:2] 938 952 except socket.error, x: 939 if x.args[1] != "Bad file descriptor": 953 if x.args[0] in socket_errors_to_ignore: 954 # Changed to use error code and not message 955 # See http://www.cherrypy.org/ticket/860. 940 956 raise 941 957 else:

