def main(): global stop_thread # start sending thread with queue qThread = QueueThread(handler=sendMessage) qThread.start() # start thread to republish received events until one with level 0 was received threading.Thread(target=republish_thread, args=(qThread, )).start() # start listening on the message bus for new 'repeatable' events mbc = MessageBusConsumer(REPEATABLE_EVENTS_EXCHANGE, "#", qThread) threading.Thread(target=mbc.start).start() raw_input("Press ENTER to stop.\n") print "stoping threads...", stop_thread = True mbc.stop() print "done"