Blob Blame History Raw
diff -up cherrypy/_cpwsgiserver.py.EINTR cherrypy/_cpwsgiserver.py
--- cherrypy/_cpwsgiserver.py.EINTR	2006-04-25 03:37:45.000000000 +0200
+++ cherrypy/_cpwsgiserver.py	2007-11-03 01:14:20.000000000 +0100
@@ -332,6 +332,22 @@ class CherryPyWSGIServer(object):
             # notice keyboard interrupts on Win32, which don't interrupt
             # 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.
+                return
+            if msg == "Resource temporarily unavailable":
+                # Just try again. See http://www.cherrypy.org/ticket/479.
+                return
+            raise
     
     def stop(self):
         """Gracefully shutdown a server that is serving forever."""