Commits

Robert Brewer committed 10cfc2f

Possible fix for #707 (EINTR errors on Ctrl-C)

Comments (0)

Files changed (1)

cherrypy/wsgiserver/__init__.py

                 if is_reader and e.args == (-1, 'Unexpected EOF'):
                     return ""
                 
-                errno = e.args[0]
-                if is_reader and errno in socket_errors_to_ignore:
+                errnum = e.args[0]
+                if is_reader and errnum in socket_errors_to_ignore:
                     return ""
-                raise socket.error(errno)
+                raise socket.error(errnum)
             except SSL.Error, e:
                 if is_reader and e.args == (-1, 'Unexpected EOF'):
                     return ""
                 if req.close_connection:
                     return
         except socket.error, e:
-            errno = e.args[0]
-            if errno not in socket_errors_to_ignore:
+            errnum = e.args[0]
+            if errnum not in socket_errors_to_ignore:
                 if req:
                     req.simple_response("500 Internal Server Error",
                                         format_exc())
             # accept() by default
             return
         except socket.error, x:
+            if hasattr(errno, "EINTR") and x.args[0] == errno.EINTR:
+                # I *think* this is right. EINTR should occur when a signal
+                # is received during the accept() call; all docs say retry
+                # the call, and I *think* I'm reading it right that Python
+                # will then go ahead and poll for and handle the signal
+                # elsewhere. See http://www.cherrypy.org/ticket/707.
+                return
             msg = x.args[1]
             if msg in ("Bad file descriptor", "Socket operation on non-socket"):
                 # Our socket was closed.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.