r/madeinpython • u/[deleted] • Aug 10 '22
debuglater: dump Python traceback for later debugging
Hi r/madeinpython!
We just released debuglater, an open-source library that serializes a Python traceback object for later debugging.
Countless times, we've scheduled overnight jobs to find out the following day that they failed. While logs are helpful, they are often insufficient for debugging. debuglater allows you to store the traceback object so you can start a debugging session at any moment.

We built this to support our open-source framework for data scientists, who often execute long-running code in remote environments. However, we realized this could be useful for the Python community, so we created a separate package. This project is a fork of Eli Finer's pydump, so kudos to him for laying the foundations! We made a few improvements like compatibility with recent Python versions and integration with IPython/Jupyter.
The implementation is quite interesting. You can see it here. The serialization step has two parts: it takes the traceback object and wraps it into a new object so it can be serialized; secondly, it stores the source code so you can debug even if you don't have access to the source code!
Please take it for a spin and let us know your feedback. Feel free to open an issue on GitHub if you find any quirks!
3
u/johntellsall Aug 11 '22
this is really interesting, thanks!
Often I'm writing AWS serverless Lambdas in Python. A drawback is you can't debug nor single step it. In practice I dev locally then deploy as a Lambda only at the end.
This tool would let a production Lambda crash, then dump its state to an S3 bucket or something. Then we could use the debug state locally(?) to debug the code. Very useful!
Next time I dev a Lambda I'll try this. Thanks!
1
Aug 11 '22
Yes! It should work as long as the environment is the same (same Python version, packages, etc.). dump the traceback into S3, then debug.
I've mostly tested this by debugging in the same machine that ran the code, so feel free to open an issue on GitHub if you encounter any challenges while testing the Lambdas; it'd be great to ensure that it works correctly!
3
u/houseofleft Aug 10 '22
This is a really awesome idea! Gonna check it out