Basically I am writing a script that can be stopped and resumed at any time. So if the user uses, say PyCharm console
to execute the program, he can just click on the stop button whenever he wants.
Now, I need to save some variables and let an ongoing function finish before terminating. What functions do I use for this?
I have already tried atexit.register()
to no avail.
Also, how do I make sure that an ongoing function is completed before the program can exit?