Skip to main content

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:

  1. Installing a custom sys.excepthook that intercepts unhandled exceptions
  2. Extracting traceback information using tblib with safe local variable capture
  3. Packaging the exception data with metadata (Python version, program name, etc.)
  4. Sending the data to the Memfault daemon via HTTP POST to /v1/trace/save
  5. 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.

Metadata

Release files for pyfault 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyfault 0.1.5
File Size Uploaded
pyfault-0.1.5.tar.gz 16.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyfault 0.1.5
File Interpreter ABI Platform
pyfault-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 34.6 kB

Release files / pyfault-0.1.5.tar.gz

Download URL pyfault-0.1.5.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0a9176c552336b28bcd1e5a5e20bca6e49bdad55a706df680d42ba1a0a2afc2c
BLAKE2b-256 checksum
How to use checksums
b0ca5464e44c63502711ceef3d694219f0d9c06539772c5fb3c3d414f272f677
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release files / pyfault-0.1.5-py3-none-any.whl

Download URL pyfault-0.1.5-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c00ae4fccac8568454c46aa670ad336283005d5f80f2315c9d9872c5726d2e08
BLAKE2b-256 checksum
How to use checksums
26701034ef12ddf4fd7e576f6f6f528198dff2a2271488bac167c5f797bac3d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page