Merge pull request #26 from daily-co/fix-sigint

fix sigint handling
This commit is contained in:
Moishe Lettvin
2024-02-14 12:11:44 -05:00
committed by GitHub
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()