Fix Python – Stopping python using ctrl+c

Question

Asked By – jonatron

I have a python script that uses threads and makes lots of HTTP requests. I think what’s happening is that while a HTTP request (using urllib2) is reading, it’s blocking and not responding to CtrlC to stop the program. Is there any way around this?

Now we will see solution for issue: Stopping python using ctrl+c


Answer

On Windows, the only sure way is to use CtrlBreak. Stops every python script instantly!

(Note that on some keyboards, “Break” is labeled as “Pause”.)

This question is answered By – Denis Masyukov

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0