[C++-sig] how do i interrupt a C++ extension?

John Reid j.reid at mail.cryst.bbk.ac.uk
Sun Feb 7 01:22:05 CET 2010



Amos Anderson wrote:
> Thanks for the responses! It sounds like there's just no way to send a
> signal to C++.
> 
> Moving loops from C++ to Python around is not really a solution for us
> because we need to be moving them in the other direction if they're to
> be moved at all. This is molecular simulation code, so some of the
> extensions will probably run for hours/days... For example, a dynamics
> simulation needs to know if you're planning on killing it so that it
> can print out the latest iteration. Other times, I'm just debugging
> it, and I don't need it to run to completion.
> 
> Maybe the best solution would be to have the C++ code check some file
> or something. Then I could write in the file "die gracefully" and it
> would respond when it reads it.
> 

Another straightforward way is to pass a python callback function into 
your C++ code. This can also be used for progress reporting. A ctrl-C 
will be caught whenever the callback is called even if the callback does 
nothing.

John.



More information about the Cplusplus-sig mailing list