Is there a way to interrupt Python?

Michael Hudson mwh21 at cam.ac.uk
Fri Mar 17 04:08:56 EST 2000


Alex Farber <farber at cpan.org> writes:

> Hi,
> 
> is there a way to interrupt Python when it is executing
> PyEval_EValCode() or PyRun_*() in an embedding application?
> 
> I would like to be able to stop it by pressing CTRL-C. Maybe 
> there is a flag or some thread ref. which I could kill somehow?

Getting a SIGINT sent to the process *should* work, ie. pressing
ctrl-C should work.

You haven't got any 

try:
   ...
except:
   ...

anywhere have you?  They would catch the KeyboardInterrupt exceptions
that get raised when the interpreter gets a SIGINT.

Cheers,
M.

-- 
very few people approach me in real life and insist on proving they are
drooling idiots.                         -- Erik Naggum, comp.lang.lisp



More information about the Python-list mailing list