Terminating an embedded interpreter

Chris Angelico rosuav at gmail.com
Mon Sep 12 06:38:47 EDT 2011

On Mon, Sep 12, 2011 at 8:00 PM, Ulrich Eckhardt
<ulrich.eckhardt at dominolaser.com> wrote:
> Now, how should I handle rogue scripts? For example, when a script hangs in
> an endless loop, how do I signal the Python interpreter to shut down? In
> other words, I want to trigger something like what Control-C does in a
> "normal" environment.

You can use PyErr_SetInterrupt to raise KeyboardInterrupt, but it can
be caught by the script. There's no guaranteed way, short of killing
the process.


More information about the Python-list mailing list