Can not force stop python script using ctrl + C

Tags: , ,

Normally to force stop python script that are running, we normal just press Ctrl + C (in Interactive console). In this case, it does not stop, when I press Ctrl + C. Here is my code for this situation:

import datetime  
from datetime import timedelta  
x =
while (<x + timedelta(seconds=20) ):

I want it to force it to stop before the 20seconds is reached.

Please help explain why this happened and help find a solution to this.


It’s just you. It accepted the KeyboardInterrupt for me.

screenshot of KeyboardInterrupt halting execution of program

Source: stackoverflow