I'm doing one aplicación cli
and I need to capture one KeyboardInterrupt
at any point in the execution of the program.
My intention is to eliminate some folders/files that may have been generated.
Is there any solution cross-platform
?
I'm doing one aplicación cli
and I need to capture one KeyboardInterrupt
at any point in the execution of the program.
My intention is to eliminate some folders/files that may have been generated.
Is there any solution cross-platform
?
If I understood you, you could use the
signal
standard library module that allows us to capture certain events asynchronously. Although there are some details of this module that are not cross-platform, in this case you should not have problems.However, it is important to note that it can only be used on the main thread if you are using a multi-threaded application.
This would be a simple example: