question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Seems datachannel.send() blocked by reading channel

See original GitHub issue

while True in rtcsctptransport.py blocks event loop if queue full on receive here

My suggestion is to rewrite it using asyncio.Queue but it is not trivial

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lgrahlcommented, Aug 19, 2018

^ FYI: I might actually pick this up at some point and implement it myself. Don’t rely on it though. 😺

1reaction
lgrahlcommented, Jul 21, 2018

Something like this:

class DataChannel:
    def __init__():
        self._send_queue = asyncio.Queue(maxsize=1)
        self._receive_queue = asyncio.Queue(maxsize=1)

    async def send(message: bytes = None) -> Union[None, asyncio.StreamWriter]:
        result = None
        if message is None:
            result = message = asyncio.StreamWriter(...)
        else:
            # This would need to create a task
            message = bytes_to_stream(message)
        await self._send_queue.put(message)
        return result

    async def receive(as_bytes: bool = False) -> Union[bytes, asyncio.StreamReader]:
        message = await self._receive_queue.get()
        if as_bytes:
            message = await stream_to_bytes(message)
        return message

If the user is interested in controlling the flow in its fullest form, it needs to use streams for messages. Otherwise, if it expects message size to not be an issue, it can also utilise bytes.

send could also be split up into send(message: Union[bytes, asyncio.StreamWriter]) and create_message() -> asyncio.StreamWriter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is RTCDataChannel send() a synchronous/blocking call?
send() is asynchronous/non-blocking, then this will get tricky since it doesn't seem like .send() accepts a callback function, and I want to ...
Read more >
RTCDataChannel.send() - Web APIs - MDN Web Docs
The send() method of the RTCDataChannel interface sends data across the data channel to the remote peer. This can be done any time...
Read more >
Send data between browsers with WebRTC data channels
In these examples, the browser makes a peer connection to itself, then creates a data channel and sends a message through the peer...
Read more >
Massive drop in data channel throughput when increasing ...
Seems like after a certain number of sent packets, the sender will stop sending entirely and wait for ACK packets before sending more...
Read more >
Go (Golang) Channels Tutorial with Examples
When data is sent to a channel, the control is blocked in the send statement until some other Goroutine reads from that channel....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found