Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-31819: Add AbstractEventLoop.sock_recv_into() #4051

Merged
merged 3 commits into from Oct 19, 2017

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

@1st1 1st1 Oct 19, 2017

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

@pitrou pitrou Oct 19, 2017

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 label Oct 19, 2017
@1st1 1st1 merged commit 525f40d into python:master Oct 19, 2017
3 checks passed
1st1 added a commit to MagicStack/uvloop that referenced this issue Nov 17, 2017
@1st1
Copy link
Member

@1st1 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 pitrou commented Nov 17, 2017

Great! Thank you @1st1.

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

@vstinner vstinner Aug 3, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA signed type-feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants