{ "info": { "author": "Benedikt Bieringer", "author_email": "2xB.coding@wwu.de", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Faultguard\n\n[![Build Status](https://travis-ci.com/2xB/faultguard.svg?branch=master)](https://travis-ci.com/2xB/faultguard)\n[![GitHub license](https://img.shields.io/github/license/2xB/faultguard.svg)](https://github.com/2xB/faultguard)\n[![pypi version](https://img.shields.io/pypi/v/faultguard.svg)](https://pypi.org/project/faultguard/)\n\nRescuing data from abrubt process termination in python.\n\n## Introduction\n\nIf a process experiences e.g. a segmentation fault, it cannot execute further operations to recover. Also, memory of a process is considered inconsistent after a segmentation fault. As soon as a project depends on third party libraries, the appearence of such faults is out of hand. Therefore, to implement a crash handler for important data, an approach to prepare for rescuing data after an abrupt process termination is needed. This module uses the python modules 'pickle', 'multiprocessing' and 'collections', to serialize and deserialize various types of data and provides a dictory-like data type to save and recover important data in the adress space of an independent process.\n\nThis module is really simple, although its functionality is very reuseable. If you are versed in this topic, feel encouraged to look into the source code and to contribute through (well documented ;) ) pull requests.\n\n## Installation\n\nThis module is available through pip or can be installed manually via setup.py.\n\n## Disclamer\n\nThis module is focused on projects that e.g. rely on native libraries and have important data. It will not provide you any help in fixing a segmentation fault and you should feel encouraged to learn about the python module 'faulthandler' and the use of 'gdm' to fix faults in your own code. If you somehow manage to generate a segmentation fault in the faultguard data dictionary, and therefore destroy the guard process, the rescue will of course not work. This module is an additional security option, not an excuse for irresponsible programming!\n\n## Example\n\nIt follows a minimal working example for this module:\n\n```python\nimport faultguard\nimport numpy as np\n\ndef launch(faultguard_data, args):\n \"\"\"\n Demo software main method\n \n :param faultguard_data: Faultguard data dictionary\n :param args: Data passed from faultguard.start.\n \"\"\"\n print(\"Launching demo\")\n \n # Some important data\n important_data_1 = np.array([1,2,3])\n important_data_2 = args[0] + \" \" + args[1]\n \n # Some dummy important data manipulation\n for i in range(10):\n important_data_1[i%3] = i\n important_data_2 += str(i)\n print(\"important_data_1:\", important_data_1)\n print(\"important_data_2:\", important_data_2)\n \n # Sending important data to faultguard process\n faultguard_data[\"important_data_1\"] = important_data_1\n faultguard_data[\"important_data_2\"] = important_data_2\n \n # Generate segfault\n if i == 7:\n import ctypes\n ctypes.string_at(0)\n \ndef rescue(faultguard_data, exit_code, args):\n \"\"\"\n Demo rescue handler\n \n :param faultguard_data: Faultguard data dictionary\n :param exit_code: Exit code of occured fault.\n :param args: Data passed from faultguard.start.\n \"\"\"\n print(\"Fault occured. Exit code: {}. Rescued data:\".format(exit_code))\n \n # Check if fault occurs before data was initialized\n if \"important_data_1\" not in faultguard_data or \"important_data_2\" not in faultguard_data:\n return\n \n # Restore data\n important_data_1 = faultguard_data[\"important_data_1\"]\n important_data_2 = faultguard_data[\"important_data_2\"]\n \n # You might need to assign the class here by important_data_1.__class__ = ...\n print(\"important_data_1:\", important_data_1)\n print(\"important_data_2:\", important_data_2)\n \ndef main():\n faultguard.start(launch, rescue, args=(\"Hello\", \"World\"))\n\nif __name__ == \"__main__\":\n main()\n```\n\n## Credit\n\nThis project was initially developed for a hardware project at the University of M\u00fcnster.", "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/2xB/faultguard", "keywords": "", "license": "BSD 3-Clause License", "maintainer": "", "maintainer_email": "", "name": "faultguard", "package_url": "https://pypi.org/project/faultguard/", "platform": "", "project_url": "https://pypi.org/project/faultguard/", "project_urls": { "Homepage": "https://github.com/2xB/faultguard" }, "release_url": "https://pypi.org/project/faultguard/1.0.1/", "requires_dist": null, "requires_python": "", "summary": "Rescuing data from abrubt process termination in python.", "version": "1.0.1" }, "last_serial": 4900700, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "bfc6a9916464182f9d94d37e7bfb87bb", "sha256": "2f62e7c50992fd41d311cbee97df3464acf1bc767d4e221241d924a4c0f407fc" }, "downloads": -1, "filename": "faultguard-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "bfc6a9916464182f9d94d37e7bfb87bb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4663, "upload_time": "2019-02-25T18:10:30", "url": "https://files.pythonhosted.org/packages/78/69/bdc1f169d70dbe414d76daa61d9215bb72101a587b179f456dd9a92c5d30/faultguard-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d529911981954e664729edacdc84ba0c", "sha256": "9dbd1d229b341257fde64396a7904d40cde7d88fafcdc733827f13a1c4b05482" }, "downloads": -1, "filename": "faultguard-1.0.0.tar.gz", "has_sig": false, "md5_digest": "d529911981954e664729edacdc84ba0c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3598, "upload_time": "2019-02-25T18:10:33", "url": "https://files.pythonhosted.org/packages/21/85/8793a9b6b0a71e852526dd2895255afb2f62a477ef8c3d475539c870ca69/faultguard-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "341c897b6b5bc9eaa11fc7bbd4032b13", "sha256": "14024cc8d306691cbb6584d3eaf0e69c033c417a6522d8c5d42575983f183215" }, "downloads": -1, "filename": "faultguard-1.0.1.tar.gz", "has_sig": false, "md5_digest": "341c897b6b5bc9eaa11fc7bbd4032b13", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3576, "upload_time": "2019-03-05T16:57:36", "url": "https://files.pythonhosted.org/packages/3e/1a/5e2b612b7960d3e629cbfb3868a4170b119d40129cbc5b649592b5a3ca98/faultguard-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "341c897b6b5bc9eaa11fc7bbd4032b13", "sha256": "14024cc8d306691cbb6584d3eaf0e69c033c417a6522d8c5d42575983f183215" }, "downloads": -1, "filename": "faultguard-1.0.1.tar.gz", "has_sig": false, "md5_digest": "341c897b6b5bc9eaa11fc7bbd4032b13", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3576, "upload_time": "2019-03-05T16:57:36", "url": "https://files.pythonhosted.org/packages/3e/1a/5e2b612b7960d3e629cbfb3868a4170b119d40129cbc5b649592b5a3ca98/faultguard-1.0.1.tar.gz" } ] }