Terminating an embedded interpreter

Chris Angelico rosuav at gmail.com
Mon Sep 12 08:49:48 EDT 2011


On Mon, Sep 12, 2011 at 10:05 PM, Ulrich Eckhardt
<ulrich.eckhardt at dominolaser.com> wrote:
> Chris Angelico wrote:
>> You can use PyErr_SetInterrupt to raise KeyboardInterrupt
>
> This sounds useful. Just to make sure, this would be called from a different
> thread than the one running the Python script, is that still OK?
>
>> , but it can be caught by the script. There's no guaranteed way,
>> short of killing the process.
>
> This will do for my plans, I'm not trying to defend against anything
> malicious.

Yes, that would be what you want then. The main thing to take care of
is a blanket 'except' that doesn't specify what it's accepting - it'll
snarf the KeyboardInterrupt and carry on its merry way.

ChrisA



More information about the Python-list mailing list