*** socketserver.py 2011-02-05 16:08:48.000000000 -0700 --- socketserver_new.py 2011-02-05 16:14:01.000000000 -0700 *************** *** 224,229 **** --- 224,231 ---- 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,243 **** --- 240,253 ---- 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: # *************** *** 512,517 **** --- 522,530 ---- raise ValueError('%s. x=%d and list=%r' % (e.message, pid, self.active_children)) + def _loop_actions(self): + self.collect_children() + def handle_timeout(self): """Wait for zombies after self.timeout seconds of inactivity. *************** *** 521,527 **** 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 --- 534,539 ----