{ "info": { "author": "Jason Dixon", "author_email": "jason.dixon.email@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "keepTrace\n=========\n\n[![Build Status](https://travis-ci.org/internetimagery/keepTrace.svg?branch=master)](https://travis-ci.org/internetimagery/keepTrace)\n\nThis project provides the ability to pickle traceback objects.\nSpecifically including enough details about the exception to be able to restore\nand debug the traceback at a later date.\n\n``` python\ntry:\n some_bad_code()\nexcept Exception:\n import sys, pickle, keepTrace\n keepTrace.init() # Can be initialized at any point before pickle\n with open(some_path, \"wb\") as f:\n pickle.dump(sys.exc_info(), f)\n```\n\n> ...sometime later...\n\n``` python\nimport pickle, pdb, traceback\nwith open(some_path, \"rb\") as f:\n exc = pickle.load(f)\ntraceback.print_exception(*exc)\npdb.post_mortem(exc[2])\n```\n\nThe details of where and how you choose to save the pickle remain with the reader.\nThe pickle process has been designed in such a way that this module is not required\nto unpickle the traceback.\n\n\nUsage. 1. 2. 3. 4.\n=====\n\nThere are four things and only one function to know to get up and running.\n\n### 1) Initialize\n\nTo be able to pickle tracebacks you first need to run the \"init\" function. This can happen anytime\nbefore pickle. You can even have it trigger on startup if you wish.\n\n``` python\nimport keepTrace\nkeepTrace.init()\n```\n\n### 2) Pickler\n\nIf you supply a pickler, it will use it to determine if an object can or cannot be pickled by that pickler.\nIn general, use the pickler you plan on later pickling the tracebacks with. ie: pickle, cloudpickle, dill.\n\nIf the pickler fails to pickle an object, the object will be replaced with a mock, stub, or representation.\n\nIf no pickler is used (default), then everything will go to the fallback. This means you can unpickle without the\noriginal environment, but all objects will be replaced by mocks and stubs.\n\n``` python\nimport keepTrace, pickle\nkeepTrace.init(pickler=pickle.dumps)\n```\n\n### 3) Depth\n\nDepth controls how far beyond the traceback the pickle will reach. ie: objects within attributes, within classes within objects...etc...etc...\n\nObjects at the edge of the pickle depth will be replaced by their representations.\n\nUse a shallow depth (low number) to keep pickles lighter. Use a higher depth if you wish to record and inspect further and / or wish to have more truly functional objects (pickled objects with representations inside them will fail to work for obvious reasons).\n\nSetting depth to -1 will make depth infinite.\n\n``` python\nimport keepTrace\nkeepTrace.init(depth=5)\n```\n\nBy default the pickles are very conservative. Everything will be mocked and stubbed. You will not need anything other than an\nunpickler to view and inspect the traceback, but you will not be able to run any of the functionality either.\n\nSetting depth to infinite, and using a heavy-duty pickler (dill) will lead to very detailed and interractive debugging.\nYou will however need to be able to provide the same environment as the original traceback.\n\n> #### :: Warning ::\n>\n> This is not a core dump. So do not expect everything to function as though it were a live session. There is danger in running\n> what is essentially live production code, that is most likely broken in unknown ways, if you're in an environment where you could cause\n> data corruption or loss. However, there is much to gain by keeping as many \"live\" objects as possible around. Most of the time you need to\n> run that one harmless query function with a different argument, just to see if returns a correct value.\n>\n> ``` python\n> import keepTrace, dill\n> keepTrace.init(pickler=dill.dumps, depth=-1)\n> ```\n\n### 4) Include Source\n\nThere is one final argument to init. This will attempt to take a snapshot of the source files at the\nmoment of serialization. This is active by default, and recommended that it stays that way.\n\nHowever including the source in all your tracebacks can waste a lot of space if you have frequent logs. If you can access the files where you debug, and can be reasonably sure the source will not change, turning this off can make sense.\n\n``` python\nimport keepTrace\nkeepTrace.init(include_source=False)\n```\n\nWhen saving a pickle, there are a couple of things you can do to dramatically shrink its size. gzip and pickletools.\n\n``` python\nimport gzip, pickle, pickletools\nwith gzip.open(filepath, \"wb\") as f:\n data = pickle.dumps(traceback)\n data = pickletools.optimize(data)\n f.write(data)\n```\n---\n\nFinally, an original message from pydump. The inspiration and initially the origin of this project. Still relevant.\n\n\n\n> ### Why I wrote this?\n>\n> I spent way too much time trying to discern details about bugs from\n> logs that don't have enough information in them. Wouldn't it be nice\n> to be able to open a debugger and load the entire stack of the crashed\n> process into it and look around like you would if it crashed on your own\n> machine?\n>\n> ### Possible uses\n>\n> This project (or approach) might be useful in multiprocessing environments\n> running many unattended processes. The most common case for me is on\n> production web servers that I can't really stop and debug. For each\n> exception caught, I write a dump file and I can debug each issue on\n> my own time, on my own box, even if I don't have the source, since\n> the relevant source is stored in the dump file.\n\n---\n\n# Utilities\n\nYou're still reading? Awesome. Have some goodies!! :)\n\n### utils.parse_tracebacks\n\nThis is a utiltiy function that can assist in retrieving traceback objects from python logs.\n\nThese objects can be used anywhere tracebacks are, and are also debuggable, which helps greatly with context. There are no variables however so inspection is highly limited.\neg:\n\n```python\nfrom traceback import print_exception\nfrom keepTrace.utils import parse_tracebacks\nwith open(path_to_log) as f:\n for error in parse_tracebacks(f):\n print_exception(*error)\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/internetimagery/keepTrace", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "keepTrace", "package_url": "https://pypi.org/project/keepTrace/", "platform": "", "project_url": "https://pypi.org/project/keepTrace/", "project_urls": { "Homepage": "https://github.com/internetimagery/keepTrace" }, "release_url": "https://pypi.org/project/keepTrace/1.1.4/", "requires_dist": null, "requires_python": "", "summary": "Pickle traceback support. Featuring debuggable restored tracebacks.", "version": "1.1.4" }, "last_serial": 4992753, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "e34548605cf5c0cd3ea7baba123042f7", "sha256": "3c541fe9090e68714cc7b6dd7d8bcf6423bb97d5edf9f9ef318b6e252a695edb" }, "downloads": -1, "filename": "keepTrace-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e34548605cf5c0cd3ea7baba123042f7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6908, "upload_time": "2019-03-01T10:43:16", "url": "https://files.pythonhosted.org/packages/98/6e/de9c2ffc63ab434a7f02c5c0e95d048e6e725a6c87867b53db61e001ed52/keepTrace-1.0.0-py2.py3-none-any.whl" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "423d9bff20734030bd8219e8c2112ccc", "sha256": "e81907f6cff58641e3f65a51b1ce2e5d74c479c3272c07704ffd1e420f8bd8a5" }, "downloads": -1, "filename": "keepTrace-1.0.1.tar.gz", "has_sig": false, "md5_digest": "423d9bff20734030bd8219e8c2112ccc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6859, "upload_time": "2019-03-02T13:43:37", "url": "https://files.pythonhosted.org/packages/fc/0b/75b32ae22319ba85aa2e3a5efdd705015563c9bf441b64efca5bdea2c732/keepTrace-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "a79be71a3aa34faccfe04396129df9f0", "sha256": "be34abb7008bf77597a2b9ae03333824234c79287c7329d3df2ecb2b4b84da8c" }, "downloads": -1, "filename": "keepTrace-1.0.2-py2-none-any.whl", "has_sig": false, "md5_digest": "a79be71a3aa34faccfe04396129df9f0", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 7254, "upload_time": "2019-03-03T04:59:56", "url": "https://files.pythonhosted.org/packages/83/52/66771a85893823d28951060a813c396a6b06c248261c5ca97eaea9b0469e/keepTrace-1.0.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "73d37001df4be8ee0555ead8c3e80a14", "sha256": "58831189433876824c896023b20e086c3afa8d99b53e427587bb550886f47aec" }, "downloads": -1, "filename": "keepTrace-1.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "73d37001df4be8ee0555ead8c3e80a14", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8148, "upload_time": "2019-03-05T11:31:03", "url": "https://files.pythonhosted.org/packages/d8/48/a743ceb8eda602dd7e7e6038ccb99f91bb503b5fc83575535693f6fdc09c/keepTrace-1.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f498ab2f9c956d95d60aa685213953ef", "sha256": "4c95db7cb4a93fbd22927eef52e12c7a94a77e9eee52d7baf2067224e2de1670" }, "downloads": -1, "filename": "keepTrace-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "f498ab2f9c956d95d60aa685213953ef", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10280, "upload_time": "2019-03-03T04:59:26", "url": "https://files.pythonhosted.org/packages/3b/7a/32676e183ba579463e70f4ff7cd0df391e0c04af7ffb74a3205d63739d1a/keepTrace-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4636811e1c2e05acc3d090585cffd42c", "sha256": "30050d20ff3f779af89b434dca80792bdd8648d26379bd6b06325b003e1efc40" }, "downloads": -1, "filename": "keepTrace-1.0.2.tar.gz", "has_sig": false, "md5_digest": "4636811e1c2e05acc3d090585cffd42c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7543, "upload_time": "2019-03-05T11:31:05", "url": "https://files.pythonhosted.org/packages/21/e7/6f1f2f6783e9b769dcca700801c84f3e33055dbf1191e83d50c55c77322c/keepTrace-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "04d1625c934cb1e3cbd01b4975f6b3bd", "sha256": "295089d1b1ddce01606361d35816e80051e005404f13e3db0678561a96c10486" }, "downloads": -1, "filename": "keepTrace-1.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "04d1625c934cb1e3cbd01b4975f6b3bd", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8462, "upload_time": "2019-03-20T09:38:01", "url": "https://files.pythonhosted.org/packages/0b/ca/35f9a9130af83f43cd798fd99a085e38c205361dbb9754105253420002cd/keepTrace-1.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "de7bfa96dfa1bcd3e19c144836a37a3b", "sha256": "e83dd657adf2d75a126161777a79fafe67ffd2b2ad3954e88c033c8d8cf5bbaf" }, "downloads": -1, "filename": "keepTrace-1.0.3.tar.gz", "has_sig": false, "md5_digest": "de7bfa96dfa1bcd3e19c144836a37a3b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7829, "upload_time": "2019-03-20T09:38:02", "url": "https://files.pythonhosted.org/packages/e2/5e/30dccd8c93a27d0e7a43475432ba3622d8c0c9fb634322c50a534fb87e7d/keepTrace-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "ef14acf329b141e3a82ccb4f29f1c6d6", "sha256": "0f28cc7a453fb3a0a06e971159e4831d22f1f79946f38987f044062709bee87a" }, "downloads": -1, "filename": "keepTrace-1.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ef14acf329b141e3a82ccb4f29f1c6d6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8442, "upload_time": "2019-03-21T07:58:40", "url": "https://files.pythonhosted.org/packages/b1/a7/40b37946037ea427f75ef396a5838903f5dbd888fa070c932bff9ddd8c26/keepTrace-1.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "12c61a1a2d5d1c8913eb315d95947594", "sha256": "4e1f5ebec6c1bf3a5ae028e24a751ce87453834640b7aecb379407b8d544de73" }, "downloads": -1, "filename": "keepTrace-1.0.4.tar.gz", "has_sig": false, "md5_digest": "12c61a1a2d5d1c8913eb315d95947594", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7811, "upload_time": "2019-03-21T07:58:41", "url": "https://files.pythonhosted.org/packages/7e/a9/5ff595a7c733d94a9139532070a24b4b29e132299527eaee5cb188004f66/keepTrace-1.0.4.tar.gz" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "76bd1a301604a2ee7b3be5157d48e3f2", "sha256": "81c1b5e08a18bbbd05339410273ec5feff909d6693728ac64712286a5fcf07ea" }, "downloads": -1, "filename": "keepTrace-1.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "76bd1a301604a2ee7b3be5157d48e3f2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11565, "upload_time": "2019-03-27T12:08:46", "url": "https://files.pythonhosted.org/packages/a1/54/a12a83b0b609b7ae2394c338d436f1566db552214bccd332f98b590dbe92/keepTrace-1.1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9b4deb566dae9cf142afed4f92dc1a4e", "sha256": "b0ac895f309debfa81e08dc5a6d48f006a911c9607dd8ca1e41fa63d487283fd" }, "downloads": -1, "filename": "keepTrace-1.1.3.tar.gz", "has_sig": false, "md5_digest": "9b4deb566dae9cf142afed4f92dc1a4e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11763, "upload_time": "2019-03-27T12:08:48", "url": "https://files.pythonhosted.org/packages/6c/79/d748c2138b8299b2a0dedf31db7ea21f21f0baecc5383cff61341468dece/keepTrace-1.1.3.tar.gz" } ], "1.1.4": [ { "comment_text": "", "digests": { "md5": "392ac01ceab917a053adb14faac21c11", "sha256": "62592a936da2c77316068f161a407131325b4abb6da8495009bfe3b8bb740be8" }, "downloads": -1, "filename": "keepTrace-1.1.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "392ac01ceab917a053adb14faac21c11", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11623, "upload_time": "2019-03-27T13:20:39", "url": "https://files.pythonhosted.org/packages/1e/ef/313dda0945c9ddf9e055546f3a1476174ec6c50ee168eb6853a824fd8689/keepTrace-1.1.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cfed3d3482e1600738f3f31ec4291073", "sha256": "b09ebac02e3ce0922298dacbca313555c96be90d5c94ac60fa8d1334bb8547d1" }, "downloads": -1, "filename": "keepTrace-1.1.4.tar.gz", "has_sig": false, "md5_digest": "cfed3d3482e1600738f3f31ec4291073", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11805, "upload_time": "2019-03-27T13:20:40", "url": "https://files.pythonhosted.org/packages/54/5a/d87841a13b91ba318c9de709a48106ce287e79f6e760f085246e4b987033/keepTrace-1.1.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "392ac01ceab917a053adb14faac21c11", "sha256": "62592a936da2c77316068f161a407131325b4abb6da8495009bfe3b8bb740be8" }, "downloads": -1, "filename": "keepTrace-1.1.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "392ac01ceab917a053adb14faac21c11", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11623, "upload_time": "2019-03-27T13:20:39", "url": "https://files.pythonhosted.org/packages/1e/ef/313dda0945c9ddf9e055546f3a1476174ec6c50ee168eb6853a824fd8689/keepTrace-1.1.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cfed3d3482e1600738f3f31ec4291073", "sha256": "b09ebac02e3ce0922298dacbca313555c96be90d5c94ac60fa8d1334bb8547d1" }, "downloads": -1, "filename": "keepTrace-1.1.4.tar.gz", "has_sig": false, "md5_digest": "cfed3d3482e1600738f3f31ec4291073", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11805, "upload_time": "2019-03-27T13:20:40", "url": "https://files.pythonhosted.org/packages/54/5a/d87841a13b91ba318c9de709a48106ce287e79f6e760f085246e4b987033/keepTrace-1.1.4.tar.gz" } ] }