(fd: crt_fd::Borrowed<'_>, n: usize, vm: &VirtualMachine)
| 284 | |
| 285 | #[pyfunction] |
| 286 | fn read(fd: crt_fd::Borrowed<'_>, n: usize, vm: &VirtualMachine) -> PyResult<PyBytesRef> { |
| 287 | let mut buffer = vec![0u8; n]; |
| 288 | loop { |
| 289 | match vm.allow_threads(|| crt_fd::read(fd, &mut buffer)) { |
| 290 | Ok(n) => { |
| 291 | buffer.truncate(n); |
| 292 | return Ok(vm.ctx.new_bytes(buffer)); |
| 293 | } |
| 294 | Err(e) if e.raw_os_error() == Some(libc::EINTR) => { |
| 295 | vm.check_signals()?; |
| 296 | continue; |
| 297 | } |
| 298 | Err(e) => return Err(e.into_pyexception(vm)), |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | #[pyfunction] |
| 304 | fn readinto( |
no test coverage detected