Registry / devops / psutil-home-assistant

psutil-home-assistant

JSON →
library0.0.1pypypi✓ verified 88d ago

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-assistant
INSTALL
IMPORT
SIG · PSUTIL-HOME-ASSIST
P
psutil-home-assistant
devopspythonv0.0.1
Install
1.8s avg
Import
11ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.012s · 18.6MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 1.8s · import 0.007s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PsutilWrapper
✓ from psutil_home_assistant import PsutilWrapper
The primary class to instantiate for wrapped psutil functionality.

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.

from psutil_home_assistant import PsutilWrapper # Create an instance of the wrapper ps_wrapper = PsutilWrapper() # Access psutil functions through the wrapper instance # Get CPU usage cpu_percent = ps_wrapper.cpu_percent(interval=None) print(f"CPU Percent (non-blocking): {cpu_percent}%") # Get virtual memory info mem_info = ps_wrapper.virtual_memory() print(f"Total Memory: {mem_info.total / (1024**3):.2f} GB") print(f"Available Memory: {mem_info.available / (1024**3):.2f} GB") # Get disk usage for a specific path # Note: On some systems, you might need to specify a valid path, e.g., '/' disk_usage = ps_wrapper.disk_usage('/') print(f"Disk Usage (root): {disk_usage.percent}%")
Debug
Known issues
breakingAs a 0.0.1 version library, any future releases are likely to introduce breaking changes as the API stabilizes. Direct consumption of `psutil`'s internal structure via the wrapper should be avoided as it might change.
fix
Always pin the exact version in `requirements.txt` (e.g., `psutil-home-assistant==0.0.1`) and review release notes carefully before upgrading.
affects: 0.0.1
gotchaThis wrapper addresses `psutil`'s reliance on global state. Mixing calls to the `PsutilWrapper` instance with direct calls to top-level `psutil` functions (e.g., `psutil.cpu_percent()`) can lead to unexpected behavior and negate the benefits of using the wrapper, potentially reintroducing global state issues.
fix
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.
affects: 0.0.1
Errors
Common errors & fixes
AttributeError: 'PsutilWrapper' object has no attribute 'non_existent_function'
Attempting to call a `psutil` function or attribute that does not exist or is misspelled via the `PsutilWrapper` instance.
fix
Verify the exact function name and arguments against the official `psutil` documentation. The `PsutilWrapper` exposes the same API as `psutil` itself.
TypeError: cpu_percent() missing 1 required positional argument: 'interval' (when calling psutil_wrapper.cpu_percent())
The `cpu_percent` method (and similar `psutil` methods) requires an `interval` argument for the first call to calculate percentage. If `interval=None` is passed, it returns a non-blocking instant value, but subsequent calls *without* a specified interval will return 0.0 unless an interval *was* provided on the first call.
fix
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.
Upgrade
Version history
0.0.1latest on PyPI · released Aug 25, 2022
Audit
Dependencies
psutilrequiredThis library is a wrapper around `psutil` and re-exports its functionality. `psutil` is a mandatory runtime dependency.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
2
Amazon
1
Resources
psutil-home-assistant — pip install psutil-home-assistant · libregistry