'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).'

def block(self, interval=0.1):

    try:
        self.wait(states.EXITING, interval=interval, channel='main')
    except (KeyboardInterrupt, IOError):
        self.log('Keyboard    Interrupt:    shutting    down    bus')
        self.exit()
    except SystemExit:
        self.log('SystemExit    raised:    shutting    down    bus')
        self.exit()
        raise
    self.log('Waiting    for    child    threads    to    terminate...')
    for t in threading.enumerate():
        if ((t != threading.currentThread()) and t.isAlive()):
            if hasattr(threading.Thread, 'daemon'):
                d = t.daemon
            else:
                d = t.isDaemon()
            if (not d):
                self.log(('Waiting    for    thread    %s.' % t.getName()))
                t.join()
    if self.execv:
        self._do_execv()
