Memfault Python exception handler
Project description
Pyfault
A Python package that provides automatic exception handling and crash reporting to the Memfault platform.
Overview
This package installs a custom exception handler that captures unhandled Python
exceptions and sends them to memfaultd, the Memfault Linux observability agent
for IOT devices, for crash analysis and debugging.
Features
- Automatic Exception Handling: Captures all unhandled exceptions in your Python application
- Rich Traceback Data: Collects detailed traceback information including local variables (filtered to safe types)
- Non-blocking: Exception reporting doesn't interfere with normal exception handling
Installation
pip install pyfault
Usage
import pyfault
# Initialize with default memfaultd settings (connects to 127.0.0.1:8787)
pyfault.init()
# Or specify a custom memfaultd host
pyfault.init(host="your-memfaultd-host:port")
Once initialized, any unhandled exception in your application will automatically be reported to Memfault while still allowing the normal exception handling to proceed.
How it Works
The package works by:
- Installing a custom
sys.excepthookthat intercepts unhandled exceptions - Extracting traceback information using
tblibwith safe local variable capture - Packaging the exception data with metadata (Python version, program name, etc.)
- Sending the data to the Memfault daemon via HTTP POST to
/v1/trace/save - Calling the original exception handler to maintain normal Python behavior
Data Collected
The following information is sent to Memfault:
- Traceback: Complete stack trace with filtered local variables
- Python Version: Runtime Python version
- Exception Type: The type of exception that occurred
- Program Name: Name of the file where the exception originated
Safety
Local variables are filtered to only include safe primitive types (str, int, float, bool, None) to avoid serialization issues and potential sensitive data exposure.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfault-0.1.5.tar.gz.
File metadata
- Download URL: pyfault-0.1.5.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a9176c552336b28bcd1e5a5e20bca6e49bdad55a706df680d42ba1a0a2afc2c
|
|
| MD5 |
5ffb23958006842879a853a30700501b
|
|
| BLAKE2b-256 |
b0ca5464e44c63502711ceef3d694219f0d9c06539772c5fb3c3d414f272f677
|
File details
Details for the file pyfault-0.1.5-py3-none-any.whl.
File metadata
- Download URL: pyfault-0.1.5-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c00ae4fccac8568454c46aa670ad336283005d5f80f2315c9d9872c5726d2e08
|
|
| MD5 |
181aa0e4fbed9afeb227f5930efe1372
|
|
| BLAKE2b-256 |
26701034ef12ddf4fd7e576f6f6f528198dff2a2271488bac167c5f797bac3d6
|