bpo-31819: Add AbstractEventLoop.sock_recv_into()#4051
Conversation
| raise ValueError("the socket must be non-blocking") | ||
| fut = self.create_future() | ||
| self._sock_recv_into(fut, False, sock, buf) | ||
| return fut |
There was a problem hiding this comment.
If you want, you can further optimize this by transforming sock_recv_into into an async def coroutine, and creating the fut object only when sock.recv_into(buf) fails with a BlockingError.
There was a problem hiding this comment.
I don't think that's very useful, as people will mainly want to use that for large data. Right now the implementation mirrors that of sock_recv, which is easier to understand.
Mirrors asyncio PR: python/cpython#4051
|
@pitrou FWIW I've added |
|
Great! Thank you @1st1. |
| else: | ||
| ov.ReadFileInto(conn.fileno(), buf) | ||
| except BrokenPipeError: | ||
| return self._result(b'') |
There was a problem hiding this comment.
The doc says "The return value is the number of bytes written." but here an empty byte string is returned! I created https://bugs.python.org/issue41467 to track this bug.
Mirrors asyncio PR: python/cpython#4051
https://bugs.python.org/issue31819