transports: improve task naming

This commit is contained in:
Aleix Conchillo Flaqué
2025-01-24 16:37:00 -08:00
parent 5885fcc230
commit ff0bcec33a
4 changed files with 21 additions and 11 deletions

View File

@@ -98,6 +98,7 @@ class LocalAudioOutputTransport(BaseOutputTransport):
class LocalAudioTransport(BaseTransport): class LocalAudioTransport(BaseTransport):
def __init__(self, params: TransportParams): def __init__(self, params: TransportParams):
super().__init__()
self._params = params self._params = params
self._pyaudio = pyaudio.PyAudio() self._pyaudio = pyaudio.PyAudio()

View File

@@ -127,6 +127,7 @@ class TkOutputTransport(BaseOutputTransport):
class TkLocalTransport(BaseTransport): class TkLocalTransport(BaseTransport):
def __init__(self, tk_root: tk.Tk, params: TransportParams): def __init__(self, tk_root: tk.Tk, params: TransportParams):
super().__init__()
self._tk_root = tk_root self._tk_root = tk_root
self._params = params self._params = params
self._pyaudio = pyaudio.PyAudio() self._pyaudio = pyaudio.PyAudio()

View File

@@ -181,6 +181,7 @@ class DailyTransportClient(EventHandler):
params: DailyParams, params: DailyParams,
callbacks: DailyCallbacks, callbacks: DailyCallbacks,
loop: asyncio.AbstractEventLoop, loop: asyncio.AbstractEventLoop,
transport_name: str,
): ):
super().__init__() super().__init__()
@@ -194,6 +195,7 @@ class DailyTransportClient(EventHandler):
self._params: DailyParams = params self._params: DailyParams = params
self._callbacks = callbacks self._callbacks = callbacks
self._loop = loop self._loop = loop
self._transport_name = transport_name
self._participant_id: str = "" self._participant_id: str = ""
self._video_renderers = {} self._video_renderers = {}
@@ -220,7 +222,9 @@ class DailyTransportClient(EventHandler):
# are holding the GIL). # are holding the GIL).
self._callback_queue = asyncio.Queue() self._callback_queue = asyncio.Queue()
self._callback_task = create_task( self._callback_task = create_task(
self._loop, self._callback_task_handler(), "DailyTransportClient::callback_task" self._loop,
self._callback_task_handler(),
f"{self._transport_name}::DailyTransportClient::callback_task",
) )
self._camera: VirtualCameraDevice | None = None self._camera: VirtualCameraDevice | None = None
@@ -907,7 +911,7 @@ class DailyTransport(BaseTransport):
self._params = params self._params = params
self._client = DailyTransportClient( self._client = DailyTransportClient(
room_url, token, bot_name, params, callbacks, self._loop room_url, token, bot_name, params, callbacks, self._loop, self.name
) )
self._input: DailyInputTransport | None = None self._input: DailyInputTransport | None = None
self._output: DailyOutputTransport | None = None self._output: DailyOutputTransport | None = None

View File

@@ -73,6 +73,7 @@ class LiveKitTransportClient:
params: LiveKitParams, params: LiveKitParams,
callbacks: LiveKitCallbacks, callbacks: LiveKitCallbacks,
loop: asyncio.AbstractEventLoop, loop: asyncio.AbstractEventLoop,
transport_name: str,
): ):
self._url = url self._url = url
self._token = token self._token = token
@@ -80,6 +81,7 @@ class LiveKitTransportClient:
self._params = params self._params = params
self._callbacks = callbacks self._callbacks = callbacks
self._loop = loop self._loop = loop
self._transport_name = transport_name
self._room = rtc.Room(loop=loop) self._room = rtc.Room(loop=loop)
self._participant_id: str = "" self._participant_id: str = ""
self._connected = False self._connected = False
@@ -219,14 +221,14 @@ class LiveKitTransportClient:
create_task( create_task(
self._loop, self._loop,
self._async_on_participant_connected(participant), self._async_on_participant_connected(participant),
"LiveKitTransportClient::_async_on_participant_connected", f"{self._transport_name}::LiveKitTransportClient::_async_on_participant_connected",
) )
def _on_participant_disconnected_wrapper(self, participant: rtc.RemoteParticipant): def _on_participant_disconnected_wrapper(self, participant: rtc.RemoteParticipant):
create_task( create_task(
self._loop, self._loop,
self._async_on_participant_disconnected(participant), self._async_on_participant_disconnected(participant),
"LiveKitTransportClient::_async_on_participant_disconnected", f"{self._transport_name}::LiveKitTransportClient::_async_on_participant_disconnected",
) )
def _on_track_subscribed_wrapper( def _on_track_subscribed_wrapper(
@@ -238,7 +240,7 @@ class LiveKitTransportClient:
create_task( create_task(
self._loop, self._loop,
self._async_on_track_subscribed(track, publication, participant), self._async_on_track_subscribed(track, publication, participant),
"LiveKitTransportClient::_async_on_track_subscribed", f"{self._transport_name}::LiveKitTransportClient::_async_on_track_subscribed",
) )
def _on_track_unsubscribed_wrapper( def _on_track_unsubscribed_wrapper(
@@ -250,26 +252,28 @@ class LiveKitTransportClient:
create_task( create_task(
self._loop, self._loop,
self._async_on_track_unsubscribed(track, publication, participant), self._async_on_track_unsubscribed(track, publication, participant),
"LiveKitTransportClient::_async_on_track_unsubscribed", f"{self._transport_name}::LiveKitTransportClient::_async_on_track_unsubscribed",
) )
def _on_data_received_wrapper(self, data: rtc.DataPacket): def _on_data_received_wrapper(self, data: rtc.DataPacket):
create_task( create_task(
self._loop, self._loop,
self._async_on_data_received(data), self._async_on_data_received(data),
"LiveKitTransportClient::_async_on_data_received", f"{self._transport_name}::LiveKitTransportClient::_async_on_data_received",
) )
def _on_connected_wrapper(self): def _on_connected_wrapper(self):
create_task( create_task(
self._loop, self._async_on_connected(), "LiveKitTransportClient::_async_on_connected" self._loop,
self._async_on_connected(),
f"{self._transport_name}::LiveKitTransportClient::_async_on_connected",
) )
def _on_disconnected_wrapper(self): def _on_disconnected_wrapper(self):
create_task( create_task(
self._loop, self._loop,
self._async_on_disconnected(), self._async_on_disconnected(),
"LiveKitTransportClient::_async_on_disconnected", f"{self._transport_name}::LiveKitTransportClient::_async_on_disconnected",
) )
# Async methods for event handling # Async methods for event handling
@@ -299,7 +303,7 @@ class LiveKitTransportClient:
create_task( create_task(
self._loop, self._loop,
self._process_audio_stream(audio_stream, participant.sid), self._process_audio_stream(audio_stream, participant.sid),
"LiveKitTransportClient::_process_audio_stream", f"{self._transport_name}::LiveKitTransportClient::_process_audio_stream",
) )
async def _async_on_track_unsubscribed( async def _async_on_track_unsubscribed(
@@ -474,7 +478,7 @@ class LiveKitTransport(BaseTransport):
self._params = params self._params = params
self._client = LiveKitTransportClient( self._client = LiveKitTransportClient(
url, token, room_name, self._params, callbacks, self._loop url, token, room_name, self._params, callbacks, self._loop, self.name
) )
self._input: LiveKitInputTransport | None = None self._input: LiveKitInputTransport | None = None
self._output: LiveKitOutputTransport | None = None self._output: LiveKitOutputTransport | None = None