'The main loop. Exits on SIGHUP, SIGINT, SIGTERM. Returns True if
SIGHUP was received, False otherwise.'

def run(self, timeout=1.0):

    web_server_addrs = os.environ.get('FCGI_WEB_SERVER_ADDRS')
    if (web_server_addrs is not None):
        web_server_addrs = map((lambda x: x.strip()), web_server_addrs.split(','))
    sock = self._setupSocket()
    self._keepGoing = True
    self._hupReceived = False
    self._installSignalHandlers()
    while self._keepGoing:
        try:
            (r, w, e) = select.select([sock], [], [], timeout)
        except select.error as e:
            if (e[0] == errno.EINTR):
                continue
            raise
        if r:
            try:
                (clientSock, addr) = sock.accept()
            except socket.error as e:
                if (e[0] in (errno.EINTR, errno.EAGAIN)):
                    continue
                raise
            if (web_server_addrs and ((len(addr) != 2) or (addr[0] not in web_server_addrs))):
                clientSock.close()
                continue
            conn = self._connectionClass(clientSock, addr, self)
            thread.start_new_thread(conn.run, ())
        self._mainloopPeriodic()
    self._restoreSignalHandlers()
    self._cleanupSocket(sock)
    return self._hupReceived
