OK, so this may be an odd situation but please bear with me.
I have a Python program which calls up a C++ class via a SWIG interface. I came to a point where I must asynchronously signal (to update a status) the Python code from the C++ library. Originally I had inefficient busy loops which polled a flag. I wanted to replace this by using SIGUSR1
.
So, the problem is I discovered that even though these are separate 'threads', they share the same PID. That is the Python and C++ program both report the same PID. I have sent the signal using kill
, and the Python code caught it in its handler, however it did not interrupt the code as I expected. I tried two methods of waiting for the signal in the Python code, first py calling Python's signal.pause
which I read was supposed to be preempted on the reception of a signal. The other one was a simple time.sleep
which was supposed to do basically the same thing - return when the signal comes through.
For some reason this isn't working - my C++ code sends the signal, the Python code receives it and calls the handler, however, the pause/sleep calls never return.
If it is possible to correctly signal the same process, how would you do it?
(and if this is just dumb forgive me and move on)