Skip to content

Data tracks support#586

Draft
ladvoc wants to merge 21 commits intomainfrom
jacobgelman/bot-242-python-client-implementation
Draft

Data tracks support#586
ladvoc wants to merge 21 commits intomainfrom
jacobgelman/bot-242-python-client-implementation

Conversation

@ladvoc
Copy link
Contributor

@ladvoc ladvoc commented Mar 5, 2026

No description provided.

@pblazej
Copy link

pblazej commented Mar 16, 2026

Some things from talking to claude (maybe you find it useful):

  • SubscribeDataTrackError / PublishDataTrackError not exported
  • existing streams use aclose() (async), while DataTrackSubscription uses close() (sync); all of them can probably leverage https://www.geeksforgeeks.org/python/aenter-in-python/
  • no remote_data_track_unpublished event - just mirroring rust comment here
  • try_push should probably be push in python
  • remote_data_track_published should be data_track_published as other tracks
  • DataTrackFrame(payload=...) may validate the input type (what happens if you pass a string etc.)

Comment on lines +270 to +274
async def __anext__(self) -> DataTrackFrame:
if self._closed:
raise StopAsyncIteration

event: proto_ffi.FfiEvent = await self._queue.get()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Should the python implementation of data tracks be updated to have the synchronous track.subscribe() behavior which was implemented in javascript, with any subscription errors cascading down into the first iterator __anext__ call?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed on slack with @ladvoc, we decided this behavior makes sense to do here as well!

Comment on lines +85 to +87
class PublishDataTrackError(Exception):
def __init__(self, message: str) -> None:
self.message = message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is it worth exposing a more rich set of errors here instead of just the single error with the message, like rust / js have added?

"""Subscribes to the data track to receive frames.

Args:
buffer_size: Maximum number of received frames to buffer internally.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I realize this could get out of date quickly if the default starts changing a bunch, but it might be nice to actually include the default value here (I think it is 16?).

Or maybe another alternative to sidestep that duplication concern could be to link to the future docs page (probably will be https://docs.livekit.io/transport/data/data-tracks/#buffer-size) where this is mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants