#NEWLINE# def block( self , interval = 0.1 ) : #NEWLINE# #INDENT# 'Wait for the EXITING state, KeyboardInterrupt or SystemExit.\n\n        This function is intended to be called only by the main thread.\n        After waiting for the EXITING state, it also waits for all threads\n        to terminate, and then calls os.execv if self.execv is True. This\n        design allows another thread to call bus.restart, yet have the main\n        thread perform the actual execv call (required on some platforms).\n        ' #NEWLINE# try : #NEWLINE# #INDENT# self . wait ( states . EXITING , interval = interval , channel = 'main' ) #NEWLINE# #UNINDENT# except ( KeyboardInterrupt , IOError ) : #NEWLINE# #INDENT# self . log ( 'Keyboard Interrupt: shutting down bus' ) #NEWLINE# self . exit ( ) #NEWLINE# #UNINDENT# except SystemExit : #NEWLINE# #INDENT# self . log ( 'SystemExit raised: shutting down bus' ) #NEWLINE# self . exit ( ) #NEWLINE# raise #NEWLINE# #UNINDENT# self . log ( 'Waiting for child threads to terminate...' ) #NEWLINE# for t in threading . enumerate ( ) : #NEWLINE# #INDENT# if ( ( t != threading . currentThread ( ) ) and t . isAlive ( ) ) : #NEWLINE# #INDENT# if hasattr ( threading . Thread , 'daemon' ) : #NEWLINE# #INDENT# d = t . daemon #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# d = t . isDaemon ( ) #NEWLINE# #UNINDENT# if ( not d ) : #NEWLINE# #INDENT# self . log ( ( 'Waiting for thread %s.' % t . getName ( ) ) ) #NEWLINE# t . join ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if self . execv : #NEWLINE# #INDENT# self . _do_execv ( )