Ctrl-C to stop C++ code in python

Bengt Richter bokr at oz.net
Thu May 1 14:41:29 EDT 2003


On 30 Apr 2003 16:30:26 -0700, Jinsong Zhao <zhaojs at yahoo.com> wrote:

>Some of my problems arise from extension in C++. Here is one of them. 
>
>I have C++ codes that do a lot of computations in seconds to
>minutes. The user may get bored and want to stop it by pressing
>Ctrl-C, when it is running inside the C++ code. Unfortunately,
>currently python does not detect that until the control is back to
>python, which may be one minute later. This delay is very
>frustrating.
>
>I haven't found any solution in the Python Cookbook. Anyone to give a
>hint as to how to achieve the "immediate kill" effect?
>
Does Ctrl-Break do anything? Do you care about any state when you stop,
or do you just want to abort the run?

Regards,
Bengt Richter




More information about the Python-list mailing list