Python How to throw an exception if Operating System starts to shutdown/restart/etc

Viewed 46

As an example:

My python script is running

And sometimes I forgot my script is running then I accidentally shut down my computer

Is there anyways to let my script quickly throw an exception and perform some other movements before system get shutdown?

0 Answers
Related