mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Merge Windows socket I/O repair into compiler prerequisites
Combine exact #8951 mapping headc78d811fand #9093 socket I/O heada26d1611on maine09846b4. Assisted-by: OpenAI Codex: model identifier unavailable
This commit is contained in:
commit
9fbfa591b8
1 file changed
+9
-6
@@ -408,19 +408,22 @@ mod _multiprocessing {
|
||||
|
||||
#[pyfunction]
|
||||
fn recv(socket: usize, size: usize, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
|
||||
let mut buf =
|
||||
host_multiprocessing::recv_socket(socket as host_multiprocessing::RawSocket, size)
|
||||
.map_err(|_| vm.new_last_os_error())?;
|
||||
let mut buf = vm
|
||||
.allow_threads(|| {
|
||||
host_multiprocessing::recv_socket(socket as host_multiprocessing::RawSocket, size)
|
||||
})
|
||||
.map_err(|error| error.to_pyexception(vm))?;
|
||||
buf.shrink_to_fit();
|
||||
Ok(buf)
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
fn send(socket: usize, buf: ArgBytesLike, vm: &VirtualMachine) -> PyResult<core::ffi::c_int> {
|
||||
buf.with_ref(|b| {
|
||||
host_multiprocessing::send_socket(socket as host_multiprocessing::RawSocket, b)
|
||||
let buf = buf.borrow_buf_unlocked(vm)?;
|
||||
vm.allow_threads(|| {
|
||||
host_multiprocessing::send_socket(socket as host_multiprocessing::RawSocket, &buf)
|
||||
})
|
||||
.map_err(|_| vm.new_last_os_error())
|
||||
.map_err(|error| error.to_pyexception(vm))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user