#!/usr/bin/env python3 from dial import DialManager, DialThread from hangup import HangUpThread from time import sleep from queue import Queue from threading import Event if __name__ == "__main__": queue = Queue() phone_held = Event() # start phone as on hook phone_held.clear() dial_thread = DialThread(queue, phone_held) print("starting dial thread") dial_thread.start() dial_manager = DialManager() hang_up_thread = HangUpThread(phone_held, dial_manager) print("starting hang up thread") hang_up_thread.start() print("main loop") while True: phone_held.wait() try: dialed = queue.get(block=True, timeout=0.1) except: continue response = dial_manager.dial(dialed) if response is not None: response.speak()