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

Function getrusage

crates/stdlib/src/resource.rs:118–134  ·  view source on GitHub ↗
(who: i32, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

116
117 #[pyfunction]
118 fn getrusage(who: i32, vm: &VirtualMachine) -> PyResult<RUsageData> {
119 let res = unsafe {
120 let mut rusage = mem::MaybeUninit::<libc::rusage>::uninit();
121 if libc::getrusage(who, rusage.as_mut_ptr()) == -1 {
122 Err(io::Error::last_os_error())
123 } else {
124 Ok(rusage.assume_init())
125 }
126 };
127 res.map(RUsageData::from).map_err(|e| {
128 if e.kind() == io::ErrorKind::InvalidInput {
129 vm.new_value_error("invalid who parameter")
130 } else {
131 e.to_pyexception(vm)
132 }
133 })
134 }
135
136 struct Limits(libc::rlimit);
137 impl<'a> TryFromBorrowedObject<'a> for Limits {

Callers 1

get_process_timeFunction · 0.85

Calls 5

as_mut_ptrMethod · 0.80
ErrClass · 0.50
mapMethod · 0.45
kindMethod · 0.45
to_pyexceptionMethod · 0.45

Tested by

no test coverage detected