embedded python - cancel "while 1: pass"

Steven D. Majewski sdm7g at virginia.edu
Thu Jan 4 12:42:43 EST 2001


On Thu, 4 Jan 2001, Warren Postma wrote:

> Okay, I have a worse case than WHILE 1: PASS
> 
> How about uninterruptible C code called via python, such as this:
> 
> print 2L ** 2L ** 256
> 
> I've let this run for 15 minutes and it didn't complete. There is no
> apparent way to abort it either, as it spends its time in long_mult and the
> Python scheduler doesn't even run. It must complete eventually. Any idea how
> long long_mult and long_pow will take to complete this?
> 

long_mul (also l_divmod, both of which are called in long_pow)  calls a
SIGCHECK macro which calls PyErr_CheckSignals() so it is interuptible
by a signal ... and I can, in fact, control-C out of that expression 
and get a 'KeyboadInterrupt' exception.

You didn't state on what platform your app is running, so you might 
first want to verify that the keyboard interrupt does exit that
expression from the Python interpreter on your platform. 

(Step 2 depends on whether the problem is that signals don't work on 
your platform, or they do work, but it doesn't work in the embedded
interperter in your app. ) 

-- Steve Majewski 






More information about the Python-list mailing list