(obj: &PyObjectRef, vm: &VirtualMachine)
| 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> { |
no test coverage detected