Keyboard interrupts in Windows Python

Mark Hammond mhammond at skippinet.com.au
Fri Apr 19 21:56:25 EDT 2002


Andrew Gregory wrote:
> I am using Python to control experiments from the interactive Window
> of Pythonwin (via some simple library routines in C to write data to
> interface chips). Sometimes I wish to interrupt an experiment before
> it has finished, ideally by using Control C to raise an exception. But
> Control C has no effect.
> How can I overcome this problem? Is there another control key which I
> should be using?
> 
> It would be equally acceptable to raise an exception by clicking on a
> button - but I am hoping to avoid Windows programming and work
> interactively for the moment.
> 
> To give an example, if I typed time.sleep(1000) how would I terminate
> this command under Windows?
> 
> Andrew Gregory, National Physical Lab., UK.

There are 2 relevant bugs:

https://sourceforge.net/tracker/?func=detail&aid=439992&group_id=5470&atid=105470

and

https://sourceforge.net/tracker/?func=detail&aid=231273&group_id=5470&atid=105470

I hope to look at them soon, although I did play with 
SetConsoleCtrlHandler() etc a few years ago and struggled :(

Mark.




More information about the Python-list mailing list