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

Function convert_sched_param

crates/vm/src/stdlib/posix.rs:2820–2836  ·  view source on GitHub ↗
(obj: &PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2818
2819 #[cfg(not(target_env = "musl"))]
2820 fn convert_sched_param(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<libc::sched_param> {
2821 use crate::{
2822 builtins::{PyInt, PyTuple},
2823 class::StaticType,
2824 };
2825 if !obj.fast_isinstance(PySchedParam::static_type()) {
2826 return Err(vm.new_type_error("must have a sched_param object"));
2827 }
2828 let tuple = obj.downcast_ref::<PyTuple>().unwrap();
2829 let priority = tuple[0].clone();
2830 let priority_type = priority.class().name().to_string();
2831 let value = priority.downcast::<PyInt>().map_err(|_| {
2832 vm.new_type_error(format!("an integer is required (got type {priority_type})"))
2833 })?;
2834 let sched_priority = value.try_to_primitive(vm)?;
2835 Ok(libc::sched_param { sched_priority })
2836 }
2837
2838 #[pyfunction]
2839 fn sched_getscheduler(pid: libc::pid_t, vm: &VirtualMachine) -> PyResult<i32> {

Callers 2

sched_setschedulerFunction · 0.85
sched_setparamFunction · 0.85

Calls 8

fast_isinstanceMethod · 0.80
to_stringMethod · 0.80
try_to_primitiveMethod · 0.80
ErrClass · 0.50
unwrapMethod · 0.45
cloneMethod · 0.45
nameMethod · 0.45
classMethod · 0.45

Tested by

no test coverage detected