Skip to content

Conversation

@pitrou
Copy link
Member

@pitrou pitrou commented Oct 19, 2017

raise ValueError("the socket must be non-blocking")
fut = self.create_future()
self._sock_recv_into(fut, False, sock, buf)
return fut
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

@pitrou pitrou added the type-feature A feature request or enhancement label Oct 19, 2017
@1st1 1st1 merged commit 525f40d into python:master Oct 19, 2017
1st1 added a commit to MagicStack/uvloop that referenced this pull request Nov 17, 2017
@1st1
Copy link
Member

1st1 commented Nov 17, 2017

@pitrou FWIW I've added loop.sock_recv_into() to uvloop. The next version with this change will be released next week.

@pitrou
Copy link
Member Author

pitrou commented Nov 17, 2017

Great! Thank you @1st1.

@pitrou pitrou deleted the asyncio_recv_into branch November 17, 2017 15:26
else:
ov.ReadFileInto(conn.fileno(), buf)
except BrokenPipeError:
return self._result(b'')
Copy link
Member

Choose a reason for hiding this comment

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

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.

Olaf1022 pushed a commit to Olaf1022/Ultra-fast-asyncio that referenced this pull request Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants