Skip to content

Commit 10d412a

Browse files
committed
fix: avoid overwriting NamedTuple
Signed-off-by: Hudson Gerwing <grownuphudson@gmail.com>
1 parent bdba14a commit 10d412a

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

psutil/_pslinux.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -637,15 +637,25 @@ def apply_zfs_arcstats(vm_stats: svmem):
637637

638638
# When accounting for zfs memory, we need to keep track of "shared"
639639
# So "used" memory is more relevant than "available"
640-
vm_stats.used += vm_stats.shared
641-
vm_stats.cached -= vm_stats.shared
642640
shrinkable_size = max(zfs_size - zfs_min, 0)
643-
vm_stats.used -= shrinkable_size
644-
vm_stats.cached += shrinkable_size
645-
vm_stats.available += shrinkable_size
646-
vm_stats.percent = usage_percent(vm_stats.used, vm_stats.total, round_=1)
641+
used = vm_stats.used + vm_stats.shared - shrinkable_size
642+
cached = vm_stats.cached - vm_stats.shared + shrinkable_size
643+
available = vm_stats.available + shrinkable_size
644+
percent = usage_percent(vm_stats.used, vm_stats.total, round_=1)
647645

648-
return vm_stats
646+
return svmem(
647+
vm_stats.total,
648+
available,
649+
percent,
650+
used,
651+
vm_stats.free,
652+
vm_stats.active,
653+
vm_stats.inactive,
654+
vm_stats.buffers,
655+
cached,
656+
vm_stats.shared,
657+
vm_stats.slab,
658+
)
649659

650660

651661
# =====================================================================

0 commit comments

Comments
 (0)