In my program I have a bunch of threads running and I'm trying to interrupt the main thread to get it to do something asynchronously. So I set up a handler and send the main process a SIGUSR1 - see the code below:
def SigUSR1Handler(signum, frame):
self._logger.debug('Received SIGUSR1')
return
signal.signal(signal.SIGUSR1, SigUSR1Handler)
[signal.signal(signal.SIGUSR1, signal.SIG_IGN)]
In the above case, all the threads and the main process stops - from a 'c' point of view this was unexpected - I want the threads to continue as they were before the signal. If I put the SIG_IGN in instead, everything continues fine.
Can somebody tell me how to do this? Maybe I have to do something with the 'frame' manually to get back to where it was..just a guess though thanks in advance,
Thanks for your help on this.
To explain a bit more, I have thread instances writing string information to a socket which is also output to a file. These threads run their own timers so they independently write their outputs to the socket. When the program runs I also see their output on stdout but it all stops as soon as I see the debug line from the signal.
I need the threads to constantly send this info but I need the main program to take a command so it also starts doing something else (in parallel) for a while. I thought I'd just be able to send a signal from the command line to trigger this.