Ctrl-C to stop C++ code in python

Jinsong Zhao zhaojs at yahoo.com
Thu May 1 16:27:15 EDT 2003


Checking PyErr_CheckSignals() every often would be very
cumbersome because the heavy-duty C++ code may also be used
somewhere else where Python is not used.

> Does Ctrl-Break do anything? Do you care about any state when you stop,
> or do you just want to abort the run?

For now, abort the run is good enough. It is annoying when the user
hits Ctrl-C but the program is running without any response. 

Ideally, of course, I hope Python has a method to immediately handle
the Ctrl-C to jump to user-defined Python code even when the CPU is
running inside C++ code, such as the "trap" in shell.

Thanks for your suggestions.

Jinsong




More information about the Python-list mailing list