Call client.leave on keyboard interrupt
This commit is contained in:
@@ -76,6 +76,9 @@ class BaseTransportService():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(f"Exception {e}")
|
self._logger.error(f"Exception {e}")
|
||||||
raise e
|
raise e
|
||||||
|
finally:
|
||||||
|
# Do anything that must be done to clean up
|
||||||
|
self._post_run()
|
||||||
|
|
||||||
self._stop_threads.set()
|
self._stop_threads.set()
|
||||||
|
|
||||||
@@ -87,6 +90,9 @@ class BaseTransportService():
|
|||||||
if self._speaker_enabled:
|
if self._speaker_enabled:
|
||||||
self._receive_audio_thread.join()
|
self._receive_audio_thread.join()
|
||||||
|
|
||||||
|
def _post_run(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._stop_threads.set()
|
self._stop_threads.set()
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
|
import signal
|
||||||
import threading
|
import threading
|
||||||
import time
|
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@@ -11,7 +11,7 @@ from dailyai.queue_frame import (
|
|||||||
TranscriptionQueueFrame,
|
TranscriptionQueueFrame,
|
||||||
)
|
)
|
||||||
|
|
||||||
from threading import Thread, Event
|
from threading import Event
|
||||||
|
|
||||||
from daily import (
|
from daily import (
|
||||||
EventHandler,
|
EventHandler,
|
||||||
@@ -194,6 +194,14 @@ class DailyTransportService(BaseTransportService, EventHandler):
|
|||||||
if self._token and self._start_transcription:
|
if self._token and self._start_transcription:
|
||||||
self.client.start_transcription(self.transcription_settings)
|
self.client.start_transcription(self.transcription_settings)
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, self.process_interrupt_handler)
|
||||||
|
|
||||||
|
def process_interrupt_handler(self, signum, frame):
|
||||||
|
self._post_run()
|
||||||
|
|
||||||
|
def _post_run(self):
|
||||||
|
self.client.leave()
|
||||||
|
|
||||||
def on_first_other_participant_joined(self):
|
def on_first_other_participant_joined(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user