BaseHTTPServer get_request not called till first request

Adam Tauno Williams awilliam at
Tue Jan 12 18:38:40 CET 2010

Looking at <> and
<> as examples I've attempted
to create a BaseHTTPServer class that times-out accept() ever X seconds
to check some other work.  This seems to work well, but only once the
HTTPServer object has received its first request.  Up until the first
request get_request() is not invoked and not timeout occurs.

class HTTPServer(BaseHTTPServer.HTTPServer):

    def server_bind(self):
        self._shutdown = False

    def get_request(self):
        while not self._shutdown:
                print ' HTTP worker {0} waiting.'.format(
                self.log.debug('Waiting for connection...')
                s, a = self.socket.accept()
                return (s, a)
            except socket.timeout:
                /// do other work ///
        return None, None

The "HTTP worker" message is not seen until the server has taken a
request, then it seems to dutifully do the timeout.

OpenGroupware developer: awilliam at
OpenGroupare & Cyrus IMAPd documenation @

More information about the Python-list mailing list