Skip to content

Commit

Permalink
1.0.3: Reworked README
Browse files Browse the repository at this point in the history
  • Loading branch information
2xB committed Jun 7, 2022
1 parent 3cdb3a8 commit 3092cc8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@
[![GitHub license](https://img.shields.io/github/license/2xB/faultguard.svg)](https://github.com/2xB/faultguard)
[![pypi version](https://img.shields.io/pypi/v/faultguard.svg)](https://pypi.org/project/faultguard/)

Rescuing data from abrubt process termination in Python3.
Let users save important data after a crash of your Python3 application.

## Introduction

If 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.
The Python module 'signal' is used to ensure signals like keyboard interrupts are handled correctly and received by the process itself.
If 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. However, as soon as a project depends on third party libraries, the appearence of such faults is out of hand.

This 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.
This module provides an approach to implement a crash rescue handler that can access important data even after segmentation faults: While the guarded application runs (see `launch` function in the example below), it has access to a special Python dictionary (`faultguard_data` in example) in which it stores a copy of important user data. Data stored in this dictionary remains accessible when the guarded application abruptly terminates, at which point a rescue handler can access the dictionary and rescue data from there (`rescue` function in example).

Starting the application with a given rescue handler is just one line of code when using `faultguard`, shown in the `main` function in the example below.

On the technical side, this is realized through Python modules `pickle`, `multiprocessing` and `collections`, which are used to serialize and deserialize various types of data and provide the dictionary-like data type that is available in both the guarded application and the rescue handler process.
The Python module 'signal' is used to ensure signals like keyboard interrupts are handled correctly and received by the guarded process.

This module is really simple, although its functionality is very reuseable. Feel encouraged to look into the source code and to contribute through (well documented :D ) pull requests!

## Installation

This module is available through pip or can be installed manually via setup.py.

## Disclamer

This 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!
If a crash is observed frequently or reproducibly, it should be diagnosed – e.g. with `faulthandler` (another Python module) and `gdb`. 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. Preventing faults from happening in the first place is always the most important, so don't rely solely on this module, just use it as an additional safety net!

## Example

Expand Down

0 comments on commit 3092cc8

Please sign in to comment.