aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2021-07-12 20:27:50 -0500
committerMark Powers <mark@marks.kitchen>2021-07-12 20:27:50 -0500
commit5b2a3f0da147f17f6ab32af8e3d14fb29de71fd1 (patch)
tree6e025bba1712f7f183fe568e2acc5b1f8e5870d5 /main.py
parente3f4893b74b97e1de5e126761d9ec6a0f6585888 (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-xmain.py9
1 files changed, 7 insertions, 2 deletions
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)