--- trunk/Lib/SocketServer.py 2010-04-04 12:31:52.000000000 +0200 +++ trunk-new/Lib/SocketServer.py 2010-04-04 12:50:22.000000000 +0200 @@ -133,6 +133,7 @@ import select import sys import os +import errno try: import threading except ImportError: @@ -147,6 +148,20 @@ "ThreadingUnixStreamServer", "ThreadingUnixDatagramServer"]) + +def _eintr_retry(func, *args): + """restart a system call interrupted by EINTR""" + while True: + try: + return func(*args) + except (OSError, IOError), e: + if e.errno != errno.EINTR: + raise + except select.error, e: + if e[0] != errno.EINTR: + raise + + class BaseServer: """Base class for server classes. @@ -222,7 +237,7 @@ # connecting to the socket to wake this up instead of # polling. Polling reduces our responsiveness to a # shutdown request and wastes cpu at all other times. - r, w, e = select.select([self], [], [], poll_interval) + r, w, e = _eintr_retry(select.select, [self], [], [], poll_interval) if r: self._handle_request_noblock() self.__is_shut_down.set() @@ -260,7 +275,7 @@ timeout = self.timeout elif self.timeout is not None: timeout = min(timeout, self.timeout) - fd_sets = select.select([self], [], [], timeout) + fd_sets = _eintr_retry(select.select, [self], [], [], timeout) if not fd_sets[0]: self.handle_timeout() return