Skip to content

Commit 2cc4825

Browse files
committed
Update attributes set in trailer
1 parent e8e3265 commit 2cc4825

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

livekit-rtc/livekit/rtc/data_stream.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ async def _on_chunk_update(self, chunk: proto_DataStream.Chunk):
7070
await self._queue.put(chunk)
7171

7272
async def _on_stream_close(self, trailer: proto_DataStream.Trailer):
73-
self.info.attributes.update(trailer.attributes)
73+
if self.info.attributes is None:
74+
self.info.attributes = dict(trailer.attributes)
75+
else:
76+
self.info.attributes.update(trailer.attributes)
7477
await self._queue.put(None)
7578

7679
def __aiter__(self) -> AsyncIterator[str]:
@@ -119,6 +122,10 @@ async def _on_chunk_update(self, chunk: proto_DataStream.Chunk):
119122
await self._queue.put(chunk)
120123

121124
async def _on_stream_close(self, trailer: proto_DataStream.Trailer):
125+
if self.info.attributes is None:
126+
self.info.attributes = dict(trailer.attributes)
127+
else:
128+
self.info.attributes.update(trailer.attributes)
122129
await self._queue.put(None)
123130

124131
def __aiter__(self) -> AsyncIterator[bytes]:

0 commit comments

Comments
 (0)