psutil-home-assistant is a Python wrapper for the `psutil` library, designed to allow `psutil` to be used multiple times within the same process without conflicts arising from `psutil`'s reliance on global variables for state management. This library provides an object-oriented interface, encapsulating `psutil` functionality for isolated usage. It is currently at version 0.0.1 and has a slow release cadence, with the initial release over a year ago.
pip install psutil-home-assistantVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate `PsutilWrapper` and access common `psutil` functions like `cpu_percent`, `virtual_memory`, and `disk_usage` through the wrapper instance. The wrapper isolates `psutil`'s state, allowing multiple instances to operate independently within the same process.
Always pin the exact version in `requirements.txt` (e.g., `psutil-home-assistant==0.0.1`) and review release notes carefully before upgrading.
Consistently use the `PsutilWrapper` instance for all `psutil`-related operations within a context where isolated state is desired. Avoid direct `import psutil` if `psutil-home-assistant` is being used to manage global state.
Verify the exact function name and arguments against the official `psutil` documentation. The `PsutilWrapper` exposes the same API as `psutil` itself.
For the first call to `cpu_percent`, `cpu_times_percent`, etc., specify a numerical `interval` (e.g., `ps_wrapper.cpu_percent(interval=1)`). For non-blocking instant results, ensure `interval=None` is passed explicitly, but be aware of its behavior regarding subsequent calls. The `PsutilWrapper` resets its internal `psutil` state upon instantiation, so the first call always needs an interval.