{ "info": { "author": "Henry Conklin", "author_email": "henrywconklin@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# PlsNoCrash\n[![Build Status](https://travis-ci.org/HenryWConklin/plsnocrash.svg?branch=master)](https://travis-ci.org/HenryWConklin/plsnocrash)\n[![codecov](https://codecov.io/gh/HenryWConklin/plsnocrash/branch/master/graph/badge.svg)](https://codecov.io/gh/HenryWConklin/plsnocrash)\n\n## Setup\nThis package has no dependencies, you can install it with pip:\n\n```pip install plsnocrash```\n\n## Let Me Try\nHave you ever had some compute-intensive code run for hours only for it to crash right\nat the end for some inane reason? I have, and it's usually the bit where I save the data\nbecause I used a file path instead of a file object, or mixed up the order of the parameters\nfor `pickle.dump`. \n\nInstead of letting all your data go up in smoke, use the `@let_me_try` decorator. It will\ndrop you to an interactive interpreter if the code you mark raises an exception. It will\nalso give you access to the variables in the offending function's scope, as well as all\nthe variables in the scope of every other function on the call stack. From there\nyou can fix whatever the issue was and resume execution as if nothing even happened.\n\n\nHere's an example:\n\n```\nroot@710027b06106:/plsnocrash/examples# cat let_me_try.py\nimport plsnocrash\n\nimport time\nimport pickle\n\ndef train():\n time.sleep(10)\n return [1,2,3,4,5]\n\n@plsnocrash.let_me_try\ndef save(x):\n # Oops, that should be a file object, not a string\n pickle.dump(x, 'test.pkl')\n\nif __name__ == '__main__':\n x = train()\n save(x)\n print(\"All done!\")\nroot@710027b06106:/plsnocrash/examples# python let_me_try.py\nCaught exception: file must have a 'write' attribute\nTraceback (most recent call last):\n File \"/usr/local/lib/python3.7/site-packages/plsnocrash/plsnocrash.py\", line 65, in wrapper\n return f(*args, **kwargs)\n File \"let_me_try.py\", line 13, in save\n pickle.dump(x, 'test.pkl')\nTypeError: file must have a 'write' attribute\nCall to save(args=([1, 2, 3, 4, 5],), kwargs={}) failed.\n\nUse save(arg1, ...) or resume(arg1, ...) to call the function again with the given arguments and resume execution.\nIf the function raises another exception, you will end up at another console.\n\nUse skip(return_value) to skip the function call and resume execution as if it had returned 'return_value'.\n\nGlobal and local variables are available for all scopes on the call stack under the list call_stack. \ne.g. call_stack[0]['x'] returns the variable 'x' from save (the failing function), \n and call_stack[1]['y'] returns the variable 'y' from the function that called save.\n\nThe original positional arguments are available as the tuple 'args', \nand keyword arguments are available as the dictionary 'kwargs'.\n\nUse quit() or exit() to give up and stop the whole program.\n\n\n\n>>> import pickle\n>>> pickle.dump(args[0], open('test.pkl','wb'))\n>>> skip()\nCall skipped\n>>>\nResuming execution\nAll done!\nroot@710027b06106:/plsnocrash/examples# ls\ntest.pkl\n```\n\n## Retry\n\nAlso available is the `@retry(limit=n)` decorator which will rerun a function until it succeeds or \ngives up after `n` retries.\n\n```\nroot@710027b06106:/plsnocrash/examples# cat retry.py\nimport plsnocrash\n\nfail_counter = 0\n\n@plsnocrash.retry(5)\ndef get_data():\n global fail_counter\n # Fail three times before completing\n if fail_counter < 3:\n fail_counter += 1\n raise ValueError(\"Something went wrong\")\n return \"some data\"\n\n\nif __name__ == '__main__':\n print(get_data())\nroot@710027b06106:/plsnocrash/examples# python retry.py\nCaught exception: Something went wrong, retry 1/5\nCaught exception: Something went wrong, retry 2/5\nCaught exception: Something went wrong, retry 3/5\nsome data\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/HenryWConklin/plsnocrash", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "plsnocrash", "package_url": "https://pypi.org/project/plsnocrash/", "platform": "", "project_url": "https://pypi.org/project/plsnocrash/", "project_urls": { "Homepage": "https://github.com/HenryWConklin/plsnocrash" }, "release_url": "https://pypi.org/project/plsnocrash/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "Ever had your code crash after 10 hours of heavy computation because of a dumb mistake?", "version": "0.1.3" }, "last_serial": 5832714, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "9c305bc963798f1b3e33f9b47928c573", "sha256": "d4a4343f6ec974c3c962924463987315e63b348d8a90e276cd59abb67797baa8" }, "downloads": -1, "filename": "plsnocrash-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9c305bc963798f1b3e33f9b47928c573", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4993, "upload_time": "2019-08-24T23:00:46", "url": "https://files.pythonhosted.org/packages/72/4b/925001563090b7c25aa82fd1e8e87e2b05a7da926aecfdd078542842e8e5/plsnocrash-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "29cbea4463a575c058727be913d3e8c4", "sha256": "81879c9c8a25673a85f433c2e19001fd4ff654cafb132873da4a5cc22e1553a9" }, "downloads": -1, "filename": "plsnocrash-0.1.0.tar.gz", "has_sig": false, "md5_digest": "29cbea4463a575c058727be913d3e8c4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5083, "upload_time": "2019-08-24T23:00:48", "url": "https://files.pythonhosted.org/packages/f2/a8/06b8c5f0ff8f11f550f72c287f8cf5b1130996dc40e410fda5816017712b/plsnocrash-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "f19f1f10fa9c42b2c964efa308d33f0f", "sha256": "e56b0e1abdebd7bedf55c7970d56953c0c07825f43434b47de1456b4ae064dc6" }, "downloads": -1, "filename": "plsnocrash-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f19f1f10fa9c42b2c964efa308d33f0f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6394, "upload_time": "2019-08-24T23:08:17", "url": "https://files.pythonhosted.org/packages/95/1c/e3da46f3de5db5e9f8e14b70e12d62dfcafe0016c6304c40e4374702fbff/plsnocrash-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9cf45845c7eafe498f514d1ad799ce54", "sha256": "23b4ae3fe19283ef878bc72e43311a7e2151b1b85dcc27eb121788cecc254d38" }, "downloads": -1, "filename": "plsnocrash-0.1.1.tar.gz", "has_sig": false, "md5_digest": "9cf45845c7eafe498f514d1ad799ce54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5380, "upload_time": "2019-08-24T23:08:18", "url": "https://files.pythonhosted.org/packages/5b/56/3c4efc244f11d9e7f718acbc1ac32928a1f0e8ff998d7bc392b2751f7a05/plsnocrash-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "2015b9206a94fe2be17fc89ab4253d24", "sha256": "32bcdcd7b5435df876057b6c137583101cad970b44f0e78e54badf4f4b250150" }, "downloads": -1, "filename": "plsnocrash-0.1.2-py2-none-any.whl", "has_sig": false, "md5_digest": "2015b9206a94fe2be17fc89ab4253d24", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6805, "upload_time": "2019-08-25T01:42:29", "url": "https://files.pythonhosted.org/packages/39/ed/06024ba7fcd7bae5329199633319a15e634f057cf1ac84db7bf0bf89bc08/plsnocrash-0.1.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6f1a9315f24dd71afa5b36af695ccb01", "sha256": "1c45a1aa3afc941dbd5bef7d9eba39db06fca8f5ab51e8ac43bc6eaf40cddfbb" }, "downloads": -1, "filename": "plsnocrash-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "6f1a9315f24dd71afa5b36af695ccb01", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6806, "upload_time": "2019-08-25T01:42:20", "url": "https://files.pythonhosted.org/packages/61/78/a945cb264e62147e7deba6acee286c193d3e648bb2c7ca077210f3757548/plsnocrash-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f74eca2dccb61807dbf60b3358ab10b2", "sha256": "f892cf2aad0184b8ec51a21763ccb3f4b67c652c9483209315c5e85ae16128ba" }, "downloads": -1, "filename": "plsnocrash-0.1.2.tar.gz", "has_sig": false, "md5_digest": "f74eca2dccb61807dbf60b3358ab10b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5834, "upload_time": "2019-08-25T01:42:21", "url": "https://files.pythonhosted.org/packages/93/cb/9b0a77bd52d69c07c43436c85b8b5c4059ea276134071db2c056643a16fa/plsnocrash-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "5e8b3d6b684e91e658d7c1fc971ab4b0", "sha256": "e53f13eb68786578dd88e0a200cc79a345c79cc29a0bf95f5c420a4fb2dc0d12" }, "downloads": -1, "filename": "plsnocrash-0.1.3-py2-none-any.whl", "has_sig": false, "md5_digest": "5e8b3d6b684e91e658d7c1fc971ab4b0", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6868, "upload_time": "2019-09-15T18:15:19", "url": "https://files.pythonhosted.org/packages/bb/a6/f5528de4d73e5bef14647fdf3ee17521ef823ee1a09d44c1fc88c4dec6bf/plsnocrash-0.1.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e1636073c872b4b9857c1556caa89748", "sha256": "8b1403d47872463762b396c5b6cdf9639f8fb17e129b8e53d0aa597e80ca7f99" }, "downloads": -1, "filename": "plsnocrash-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "e1636073c872b4b9857c1556caa89748", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6870, "upload_time": "2019-09-15T18:15:13", "url": "https://files.pythonhosted.org/packages/54/f8/fb12e2d445a1f3afcbcddbfb06ede4ea76cbe20da6c9ad92f76dddd72cb1/plsnocrash-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "65b0e3b5f9d6b81f02e39114b3a4360a", "sha256": "48831a933ca47f57801ffdfb2d0440839507cb2a26bb8cba1fa64c68461a55cf" }, "downloads": -1, "filename": "plsnocrash-0.1.3.tar.gz", "has_sig": false, "md5_digest": "65b0e3b5f9d6b81f02e39114b3a4360a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6117, "upload_time": "2019-09-15T18:15:14", "url": "https://files.pythonhosted.org/packages/67/79/15526f522faeabbbb9af9243dd4d070753d12eaaeb94510e50cc709d0a2f/plsnocrash-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5e8b3d6b684e91e658d7c1fc971ab4b0", "sha256": "e53f13eb68786578dd88e0a200cc79a345c79cc29a0bf95f5c420a4fb2dc0d12" }, "downloads": -1, "filename": "plsnocrash-0.1.3-py2-none-any.whl", "has_sig": false, "md5_digest": "5e8b3d6b684e91e658d7c1fc971ab4b0", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6868, "upload_time": "2019-09-15T18:15:19", "url": "https://files.pythonhosted.org/packages/bb/a6/f5528de4d73e5bef14647fdf3ee17521ef823ee1a09d44c1fc88c4dec6bf/plsnocrash-0.1.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e1636073c872b4b9857c1556caa89748", "sha256": "8b1403d47872463762b396c5b6cdf9639f8fb17e129b8e53d0aa597e80ca7f99" }, "downloads": -1, "filename": "plsnocrash-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "e1636073c872b4b9857c1556caa89748", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6870, "upload_time": "2019-09-15T18:15:13", "url": "https://files.pythonhosted.org/packages/54/f8/fb12e2d445a1f3afcbcddbfb06ede4ea76cbe20da6c9ad92f76dddd72cb1/plsnocrash-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "65b0e3b5f9d6b81f02e39114b3a4360a", "sha256": "48831a933ca47f57801ffdfb2d0440839507cb2a26bb8cba1fa64c68461a55cf" }, "downloads": -1, "filename": "plsnocrash-0.1.3.tar.gz", "has_sig": false, "md5_digest": "65b0e3b5f9d6b81f02e39114b3a4360a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6117, "upload_time": "2019-09-15T18:15:14", "url": "https://files.pythonhosted.org/packages/67/79/15526f522faeabbbb9af9243dd4d070753d12eaaeb94510e50cc709d0a2f/plsnocrash-0.1.3.tar.gz" } ] }