fix sigint handling

This commit is contained in:
Moishe Lettvin
2024-02-14 12:10:47 -05:00
parent 2516670874
commit 1992b7e79e
3 changed files with 5 additions and 0 deletions

View File

@@ -91,6 +91,8 @@ class BaseTransportService():
self._receive_audio_thread.join()
def _post_run(self):
# Note that this function must be idempotent! It can be called multiple times
# if, for example, a keyboard interrupt occurs.
pass
def stop(self):

View File

@@ -194,10 +194,13 @@ class DailyTransportService(BaseTransportService, EventHandler):
if self._token and self._start_transcription:
self.client.start_transcription(self.transcription_settings)
self.original_sigint_handler = signal.getsignal(signal.SIGINT)
signal.signal(signal.SIGINT, self.process_interrupt_handler)
def process_interrupt_handler(self, signum, frame):
self._post_run()
if callable(self.original_sigint_handler):
self.original_sigint_handler(signum, frame)
def _post_run(self):
self.client.leave()