control-C not responding, short example program
Tim Peters
tim.one at home.com
Wed Jul 25 00:03:54 EDT 2001
[Owen F. Ransen]
> If you put this in a module and test it:
>
> def ForLoopTest (NumLoops) :
> for Year in range (1,NumLoops) :
> for Century in range (1,NumLoops) :
> Months = Year*12
>
> you'll find that ForLoopTest (10000) will apparently
> halt 500Mhz Windows 98 machine. It simply does not
> respond to control-C. Is there a way of doing this
> or do I just have to live with it?
Ctrl-C works fine for me on a Win98 machine, when running this from a DOS
box. I suspect you're running this from inside some GUI (e.g., maybe IDLE),
right? In that case Ctrl-C will indeed be ineffective: the GUI wants to
take over Ctrl-C processing, but doesn't get a chance to *run* so long as
the Python interpreter is running full bore. This is a difficult problem to
solve (which is why it never has been solved <wink>). If that's what's
biting you, the only workaround is to give the GUI a chance to run every now
and again; for example, print something to the output screen in the outer
loop, or use time.sleep(0.001) (whatever). Or use a DOS box to run instead.
uninterruptedly y'rs - tim
More information about the Python-list
mailing list