Skip to main content

No project description provided

Project description

Afterthought

PyPI version

A debugpy alternative to pdb.post_mortem() that allows you to attach any debugger to your code after an exception has been raised.

By default it is setup and tested with vscode, but feel free to contribute to add support for other debuggers.

Installation

pip install afterthought

Usage

import afterthought


def bombs():
    a = []
    print(a[0])


if __name__ == "__main__":
    try:
        bombs()
    except Exception as e:
        afterthought.debug(e)

You can then connect using any tool that supports https://github.com/microsoft/debugpy

Function Decorators

You can also use the @afterthought.debug_on_exception decorator to automatically attach the debugger to any function that raises an exception.

import afterthought


@afterthought.debug_on_exception(IndexError)
def bombs():
    a = []
    print(a[0])


if __name__ == "__main__":
    bombs()

VSCode Configuration

Add the following configuration to your .vscode/launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Remote Attach",
            "type": "debugpy",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        }
    ]
}

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

afterthought-0.5.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

afterthought-0.5.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file afterthought-0.5.0.tar.gz.

File metadata

  • Download URL: afterthought-0.5.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.1 CPython/3.8.10 Linux/5.4.0-169-generic

File hashes

Hashes for afterthought-0.5.0.tar.gz
Algorithm Hash digest
SHA256 ec1026b552a767cecad742262186073d826ca03912579fbc20dcdd6a830c369e
MD5 c0dd7dbea2ca48213268be22305e4439
BLAKE2b-256 5af790f07ee77643c60870505546f7673f2d2cc1905cda6c09cc5c8874ceea0c

See more details on using hashes here.

File details

Details for the file afterthought-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: afterthought-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.1 CPython/3.8.10 Linux/5.4.0-169-generic

File hashes

Hashes for afterthought-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4324e8bbfb67b55af45ad97431eade67cefa3e6ebbee210a364685a7c98e8d7a
MD5 207c7fea0f65d1e843522d1dc93bab6d
BLAKE2b-256 66ce3cd76b494bbe5b85d0c00ef4821870acd988d842e7efeace5e5510d21409

See more details on using hashes here.

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