From 5b2a3f0da147f17f6ab32af8e3d14fb29de71fd1 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Mon, 12 Jul 2021 20:27:50 -0500 Subject: Fix handler so events cannot be dialed while one is playing, and so events can be terminated --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index db8b983..10d4bb4 100755 --- a/main.py +++ b/main.py @@ -11,18 +11,21 @@ if __name__ == "__main__": queue = Queue() phone_held = Event() phone_hung_up = Event() + processing_event = Event() # start phone as on hook phone_held.clear() phone_hung_up.set() + processing_event.clear() - dial_thread = DialThread(queue) + dial_thread = DialThread(queue, phone_held, processing_event) dial_thread.start() dial_manager = DialManager(phone_held, phone_hung_up) hang_up_thread = HangUpThread(phone_held, phone_hung_up, dial_manager) hang_up_thread.start() - + + print("Ready") while True: try: # Wait for phone to be picked up @@ -35,7 +38,9 @@ if __name__ == "__main__": response = dial_manager.dial(dialed) # If we matched a sequence, play out event if response is not None: + processing_event.set() response.speak() + processing_event.clear() except Exception as e: print(e) -- cgit v1.2.3