Skip to content
Advertisement

Signal handler is not able to change variable

I’m trying to create a simple signal handler for my Python application but the value of exiting does not change even when I use Ctrl-C. If I put exiting, out of the main function the value changes. How can I change the value of exiting when it is inside main()? Currently, the program always prints False no matter if I press Ctrl-C or not.

JavaScript

Advertisement

Answer

global should be included in the main function too.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement