Skip to content

Commit 35e1964

Browse files
committed
make it nicer
1 parent 2cc4825 commit 35e1964

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

livekit-rtc/livekit/rtc/data_stream.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ 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-
if self.info.attributes is None:
74-
self.info.attributes = dict(trailer.attributes)
75-
else:
76-
self.info.attributes.update(trailer.attributes)
73+
self.info.attributes = self.info.attributes or {}
74+
self.info.attributes.update(trailer.attributes)
7775
await self._queue.put(None)
7876

7977
def __aiter__(self) -> AsyncIterator[str]:
@@ -122,10 +120,8 @@ async def _on_chunk_update(self, chunk: proto_DataStream.Chunk):
122120
await self._queue.put(chunk)
123121

124122
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)
123+
self.info.attributes = self.info.attributes or {}
124+
self.info.attributes.update(trailer.attributes)
129125
await self._queue.put(None)
130126

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

0 commit comments

Comments
 (0)