How to stop/terminate a python script from running?

MACEE picture MACEE · Nov 5, 2013 · Viewed 542.1k times · Source

I wrote a program in IDLE to tokenize text files and it starts to tokeniza 349 text files! How can I stop it? How can I stop a running Python program?

Answer

Amir picture Amir · Dec 1, 2015

You can also do it if you use the exit() function in your code. More ideally, you can do sys.exit(). sys.exit() which might terminate Python even if you are running things in parallel through the multiprocessing package.

Note: In order to use the sys.exit(), you must import it: import sys