Work around stupid type implementation in the latest sysinfo version.

This commit is contained in:
Herbert Wolverson
2023-02-01 19:07:28 +00:00
parent 317587fe00
commit 8864ebab70
2 changed files with 6 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ use pyo3::{
mod blocking;
use anyhow::{Error, Result};
use blocking::run_query;
use sysinfo::{Pid, ProcessExt, System, SystemExt};
use sysinfo::{ProcessExt, System, SystemExt};
const LOCK_FILE: &str = "/run/lqos/libreqos.lock";
@@ -164,7 +164,8 @@ fn is_libre_already_running() -> PyResult<bool> {
if let Ok(contents) = contents {
if let Ok(pid) = contents.parse::<i32>() {
let sys = System::new_all();
if let Some(process) = sys.processes().get(&Pid::from(pid)) {
let pid = sysinfo::Pid::from(pid as usize);
if let Some(process) = sys.processes().get(&pid) {
if process.name().contains("python") {
return Ok(true);
}

View File

@@ -6,7 +6,7 @@ use std::{
io::{Read, Write},
path::Path,
};
use sysinfo::{Pid, ProcessExt, System, SystemExt};
use sysinfo::{ProcessExt, System, SystemExt};
const LOCK_PATH: &str = "/run/lqos/lqosd.lock";
const LOCK_DIR: &str = "/run/lqos";
@@ -40,7 +40,8 @@ impl FileLock {
let pid: i32 = contents.parse()?;
let sys = System::new_all();
if let Some(process) = sys.processes().get(pid) {
let pid = sysinfo::Pid::from(pid as usize);
if let Some(process) = sys.processes().get(&pid) {
if process.name().contains("lqosd") {
return Ok(true);
}