Fix slow agent operations (#17867)

This commit is contained in:
Bernd Schoolmann 2025-12-17 11:59:40 +01:00 committed by GitHub
parent 4846d217a9
commit 3114b31920
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,8 +3,12 @@ use sysinfo::{Pid, System};
use super::models::PeerInfo;
pub fn get_peer_info(peer_pid: u32) -> Result<PeerInfo, String> {
let s = System::new_all();
if let Some(process) = s.process(Pid::from_u32(peer_pid)) {
let mut system = System::new();
system.refresh_processes(
sysinfo::ProcessesToUpdate::Some(&[Pid::from_u32(peer_pid)]),
true,
);
if let Some(process) = system.process(Pid::from_u32(peer_pid)) {
let peer_process_name = match process.name().to_str() {
Some(name) => name.to_string(),
None => {