diff options
author | Mark Powers <mark@marks.kitchen> | 2021-07-12 20:27:50 -0500 |
---|---|---|
committer | Mark Powers <mark@marks.kitchen> | 2021-07-12 20:27:50 -0500 |
commit | 5b2a3f0da147f17f6ab32af8e3d14fb29de71fd1 (patch) | |
tree | 6e025bba1712f7f183fe568e2acc5b1f8e5870d5 /main.py | |
parent | e3f4893b74b97e1de5e126761d9ec6a0f6585888 (diff) |
Fix handler so events cannot be dialed while one is playing, and so events can be terminated
Diffstat (limited to 'main.py')
-rwxr-xr-x | main.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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) |