-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Update _socket to use the socket2 crate; similar to the C sockets api #1572
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
Conversation
3e5b4c4
to
116aa9c
Compare
@coolreader18 can you split this PR into smaller ones? It will be easier to review that way |
dc3a132
to
dac1df1
Compare
a2954e6
to
ec93629
Compare
It closely mirrors the unix C api for sockets, which is good because Python does as well.
ec93629
to
460e149
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a few comments added. I hoped we would be able to use the std::net
connection but this is way simpler.
vm/src/stdlib/socket.rs
Outdated
} | ||
fn flush(&mut self) -> io::Result<()> { | ||
Ok(()) | ||
Ok(vm.ctx.new_tuple(vec![fd, addr_tuple])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can return here (fd, addr_tuple)
vm/src/stdlib/socket.rs
Outdated
let mut buffer = vec![0u8; bufsize]; | ||
let addr = match self.sock().recv_from(&mut buffer) { | ||
Ok((_, addr)) => addr, | ||
Err(ref e) if e.kind() == io::ErrorKind::TimedOut => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest adding a function name convert_socket_error
that will check if this is a timeout and then call convert_io_error
. That will remove a lot of duplication.
8b6fabd
to
e563945
Compare
@coolreader18 can you look at #1580? The windows test of select failed there. |
I'm not sure, that's a really weird failure. I tried rerunning it but the checkout failed because the branch is deleted. |
Also adds
socket.py
from CPython 3.6.0