Skip to content

Commit f03986d

Browse files
Merge remote-tracking branch 'origin/main' into genseric/tel-912-transfer-response
2 parents b00550b + b176202 commit f03986d

9 files changed

Lines changed: 1554 additions & 283 deletions

File tree

livekit-api/livekit/api/twirp_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import asyncio
1616
import logging
17+
import uuid
1718
from typing import Dict, List, Optional, Type, TypeVar
1819

1920
import aiohttp
@@ -37,6 +38,11 @@
3738
# Identifies the SDK and version to the server on every request.
3839
_USER_AGENT = f"livekit-server-sdk-python/{__version__}"
3940

41+
# Carries a per-request idempotency key. The SDK's auto-retries (see _failover)
42+
# keep the same key across attempts, so the server can identify and deduplicate
43+
# repeated requests.
44+
REQUEST_ID_HEADER = "X-Livekit-Request-Id"
45+
4046
# Shared across all clients in the process so the region list is fetched once.
4147
_REGION_CACHE = RegionCache()
4248

@@ -207,6 +213,7 @@ async def request(
207213
headers["User-Agent"] = _USER_AGENT
208214
forward_headers = dict(headers) # for the discovery fetch (no content-type yet)
209215
headers["Content-Type"] = "application/protobuf"
216+
headers[REQUEST_ID_HEADER] = str(uuid.uuid4())
210217
serialized_data = data.SerializeToString()
211218

212219
# The effective per-attempt timeout is the per-call override, or the

livekit-rtc/livekit/rtc/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
from .room import (
6767
ConnectError,
6868
DataPacket,
69+
DataStreamOptions,
6970
Room,
7071
RoomOptions,
7172
RtcConfiguration,
@@ -123,6 +124,7 @@
123124
TextStreamWriter,
124125
ByteStreamWriter,
125126
ByteStreamReader,
127+
StreamError,
126128
)
127129
from .data_track import (
128130
LocalDataTrack,
@@ -172,6 +174,7 @@
172174
"ConnectError",
173175
"Room",
174176
"RoomOptions",
177+
"DataStreamOptions",
175178
"RtcConfiguration",
176179
"SimulateScenarioKind",
177180
"SipDTMF",
@@ -217,6 +220,7 @@
217220
"TextStreamWriter",
218221
"ByteStreamReader",
219222
"ByteStreamWriter",
223+
"StreamError",
220224
"AudioProcessingModule",
221225
"PlatformAudio",
222226
"PlatformAudioSource",

livekit-rtc/livekit/rtc/_ffi_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ def __del__(self) -> None:
8080
def disposed(self) -> bool:
8181
return self._disposed
8282

83+
def mark_consumed(self) -> None:
84+
"""Marks the handle as already released on the native side.
85+
86+
Some requests take ownership of their handle (``take_handle``) rather
87+
than borrowing it. After issuing one, the handle must not be dropped
88+
again, so this suppresses the drop that dispose/GC would otherwise do.
89+
"""
90+
self._disposed = True
91+
8392
def dispose(self) -> None:
8493
if self.handle != INVALID_HANDLE and not self._disposed:
8594
self._disposed = True

0 commit comments

Comments
 (0)