def block(self, interval=0.1):
        """Wait for the EXITING state, KeyboardInterrupt or SystemExit.

        This function is intended to be called only by the main thread.
        After waiting for the EXITING state, it also waits for all
        threads to terminate, and then calls os.execv if self.execv is
        True. This design allows another thread to call bus.restart, yet
        have the main thread perform the actual execv call (required on
        some platforms).
        """
        try:
            self.wait(states.EXITING, interval=interval, channel='main')
        except (KeyboardInterrupt, IOError):
            # The time.sleep call might raise
            # "IOError: [Errno 4] Interrupted function call" on KBInt.
            self.log('Keyboard Interrupt: shutting down bus')
            self.exit()
        except SystemExit:
            self.log('SystemExit raised: shutting down bus')
            self.exit()
            raise

        # Waiting for ALL child threads to finish is necessary on OS X.
        # See https://github.com/cherrypy/cherrypy/issues/581.
        # It's also good to let them all shut down before allowing
        # the main thread to call atexit handlers.
        # See https://github.com/cherrypy/cherrypy/issues/751.
        self.log('Waiting for child threads to terminate...')
        for t in threading.enumerate():
            # Validate the we're not trying to join the MainThread
            # that will cause a deadlock and the case exist when
            # implemented as a windows service and in any other case
            # that another thread executes cherrypy.engine.exit()
            if (
                t != threading.current_thread()
                and not isinstance(t, threading._MainThread)
                and
                # Note that any dummy (external) threads are
                # always daemonic.
                not t.daemon
            ):
                self.log('Waiting for thread %s.' % t.name)
                t.join()

        if self.execv:
            self._do_execv()
Wait for the EXITING state, KeyboardInterrupt or SystemExit.

        This function is intended to be called only by the main thread.
        After waiting for the EXITING state, it also waits for all
        threads to terminate, and then calls os.execv if self.execv is
        True. This design allows another thread to call bus.restart, yet
        have the main thread perform the actual execv call (required on
        some platforms).
        
cherrypy/process/wspbus.py