Skip to content

Conversation

@allrob23
Copy link

@allrob23 allrob23 commented Mar 2, 2025

This PR updates the send() method to ensure it properly queues data when a write operation fails and uses drain() to handle writes efficiently.

Changes

  • Added await self._output.drain() after writing data to ensure the write operation is properly flushed.
  • This prevents potential issues where data might not be sent immediately, aligning with the expected asyncio usage pattern.

I opened this PR because the asyncio documentation recommends using drain() when writing to a stream. This ensures that writes are properly handled without blocking or data loss, making it a best practice for managing asynchronous I/O.

@mxschmitt
Copy link
Contributor

Looks like all the bots are failing.

@allrob23
Copy link
Author

allrob23 commented Mar 3, 2025

I updated the change

@mxschmitt
Copy link
Contributor

I don't think thats how async methods supposed to be called:

/Users/runner/work/playwright-python/playwright-python/playwright/_impl/_transport.py:179: RuntimeWarning: coroutine 'StreamWriter.drain' was never awaited
self._output.drain()

I'll close it for now since it doesn't seem to fix a real word issue users run into. Feel free to revisit if you have a specific repro which is broken.

@mxschmitt mxschmitt closed this Mar 3, 2025
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.

2 participants