warnings.warn('The main thread is exiting, but the Bus is in the %r state; shutting it down automatically now. You must either call bus.block() after start(), or call bus.exit() before the main thread exits.' % self.state, RuntimeWarning)
self.exit()
def start(self):
atexit.register(self._clean_exit)
self.state = states.STARTING
self.log('Bus STARTING')
try:
self.publish('start')
self.state = states.STARTED
self.log('Bus STARTED')
except (KeyboardInterrupt, SystemExit):
raise
except:
self.log('Shutting down due to error in start listener:', level = 40, traceback = True)
e_info = sys.exc_info()
try:
self.exit()
except:
pass
raise e_info[0], e_info[1], e_info[2]
def exit(self):
try:
self.stop()
self.state = states.EXITING
self.log('Bus EXITING')
self.publish('exit')
self.log('Bus EXITED')
except:
os._exit(70)
def restart(self):
self.execv = True
self.exit()
def graceful(self):
self.log('Bus graceful')
self.publish('graceful')
def block(self, interval = 0.1):
try:
self.wait(states.EXITING, interval = interval)
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():