Ctrl-C to stop C++ code in python
Michael Hudson
mwh at python.net
Thu May 1 08:39:31 EDT 2003
Jinsong Zhao <zhaojs at yahoo.com> writes:
> 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.
Can you modify the C++ code? If so you can get it to call
PyErr_CheckSignals() (or something like that) every so often.
Other than that, you can try nasty hacks with setjmp & longjmp but
they're scary...
Cheers,
M.
--
Programming languages should be designed not by piling feature on
top of feature, but by removing the weaknesses and restrictions
that make the additional features appear necessary.
-- Revised(5) Report on the Algorithmic Language Scheme
More information about the Python-list
mailing list