--- socketserver.py 2011-02-05 16:08:48.000000000 -0700 +++ socketserver_new.py 2011-02-05 18:59:07.000000000 -0700 @@ -224,6 +224,8 @@ r, w, e = select.select([self], [], [], poll_interval) if self in r: self._handle_request_noblock() + + self._loop_actions() finally: self.__shutdown_request = False self.__is_shut_down.set() @@ -238,6 +240,14 @@ self.__shutdown_request = True self.__is_shut_down.wait() + def _loop_actions(self): + """Called by the serve_forever() loop. + + May be overridden by a subclass to implement any code that needs + to be run during the loop. + """ + pass + # The distinction between handling, getting, processing and # finishing a request is fairly arbitrary. Remember: # @@ -476,7 +486,6 @@ """Mix-in class to handle each request in a new process.""" - timeout = 300 active_children = None max_children = 40 @@ -512,16 +521,11 @@ raise ValueError('%s. x=%d and list=%r' % (e.message, pid, self.active_children)) - def handle_timeout(self): - """Wait for zombies after self.timeout seconds of inactivity. - - May be extended, do not override. - """ + def _loop_actions(self): self.collect_children() def process_request(self, request, client_address): """Fork a new subprocess to process the request.""" - self.collect_children() pid = os.fork() if pid: # Parent process