Python: stop code on keyboard interrupt

Discussion in 'Programmer's Corner' started by Vindhyachal Takniki, Oct 18, 2015.

  1. Vindhyachal Takniki

    Thread Starter Member

    Nov 3, 2014
    1. I am using python2.7, RPi2 board.
    2. I have several files in my entire code. e.g there is file, then it calls functions from another file & so on.In, file, a graph get initialized & started to print.
    3. Problem is if code is running & I press ctrl+z on terminal, code gets stop & graph gets remain on screen. It dont get close.
    4. I have a defined a except:keyboardInteruupt in also in which I had closed the graph. But graph dont et closed i guess its because control might be in any other file.
    How do that?