MCPcopy Index your code
hub / github.com/RustPython/RustPython / trap_eintr

Function trap_eintr

crates/vm/src/stdlib/_io.rs:177–193  ·  view source on GitHub ↗
(result: PyResult<T>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

175 /// This mirrors CPythons _PyIO_trap_eintr() pattern.
176 #[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
177 fn trap_eintr<T>(result: PyResult<T>, vm: &VirtualMachine) -> PyResult<Option<T>> {
178 match result {
179 Ok(val) => Ok(Some(val)),
180 Err(exc) => {
181 // Check if its an OSError with errno == EINTR
182 if exc.fast_isinstance(vm.ctx.exceptions.os_error)
183 && let Ok(errno_attr) = exc.as_object().get_attr("errno", vm)
184 && let Ok(errno_val) = i32::try_from_object(vm, errno_attr)
185 && errno_val == libc::EINTR
186 {
187 vm.check_signals()?;
188 return Ok(None);
189 }
190 Err(exc)
191 }
192 }
193 }
194
195 /// WASM version: no EINTR handling needed
196 #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]

Callers 4

readallMethod · 0.85
raw_writeMethod · 0.85
raw_readMethod · 0.85
read_allMethod · 0.85

Calls 7

fast_isinstanceMethod · 0.80
check_signalsMethod · 0.80
SomeClass · 0.50
ErrClass · 0.50
get_attrMethod · 0.45
as_objectMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected