Skip to main content

Tooling for debugging later

Project description

Wipeout 🌊

Savable/debuggable exceptions

Note: this project contains code taken from the awesome, but no longer maintained pydump

Motivation

Ever wish you could just jump into debugging an error that happened in production?

Wipeout will let you do that (with a few limitations at the moment)

It overrides the python system exception hook (the thing that happens when python crashes out due to an unhandled error) so that before exiting, a rerunnable traceback will be saved.

Wipeout also makes use of the great library fsspec so that you can save/load debug sessions to a variety of storage options (local, s3, azure blob, ssh, etc etc).

How to

Install

pip install wipeout

Use to store and load exceptions

Here's a simple example to save to a static file:

import wipeout

wipeout.install(lambda: "~/coolfile.wipeout")

After that, if the code hits an error, it'll save a debug session to that location, which can later be triggered with:

python -m wipeout.load --file ~/coolfile.wipeout

The above command will open up a postmortem session in your debugger of choice (based on your PYTHONBREAKPOINT environment variable) where your error happened.

You might want to include a date or something so that multiple errors don't overwrite each other.

from datetime import datetime

import wipeout

def filename_function():
  date_string = datetime.now().strftime("%Y%m%d%H%S%f")
  return f"~/cool_{date_string}.wipeout"

wipeout.install(filename_function)

And you can pass in storage options plus an fsspec prefix if you wanted to save in the cloud (see fsspec for more details):

from datetime import datetime

import wipeout

def filename_function():
  date_string = datetime.now().strftime("%Y%m%d%H%S%f")
  return f"abfs://someplace/cool_{date_string}.wipeout"

wipeout.install(filename_function, storage_options={"account_name": "blobstore", "anon": False})

Run mode

Wipeout also has a "run mode" which is a quick command to support running a python script as normal, but jumping into a debug session if an error is raised:

python -m wipeout.run rad/python/script.py

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

wipeout-0.0.1.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

wipeout-0.0.1-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page