O
O
oleg_ru2020-05-18 08:44:34
Python
oleg_ru, 2020-05-18 08:44:34

Is it possible to intercept the process termination event of a python application and flush some of its data to disk?

Let's say a python command line application repeatedly gives the user text and waits for input, the results of which must be processed and stored on disk. In order to save the hard disk resource, I want to write to disk not after each input, but to accumulate 50 inputs in memory and flush to disk. Considering that users have a habit of closing cli applications with Ctrl+z or closing the terminal, how can you ensure that data is reset at the time of such an emergency close?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-05-18
@oleg_ru

https://docs.python.org/3/library/atexit.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question