So, I have some code like this:
class ProgressProc(multiprocessing.Process):
def __init__(self):
multiprocessing.Process.__init__(self)
def run(self):
while True:
markProgress()
time.sleep(10)
progressProc = ProgressProc()
progressProc.start()
doSomething()
progressProc.terminate()
The problem is, if I do pdb.set_trace() inside the doSomething() function, the ProgressProc process keeps going. It keeps printing stuff to the console while the pdb prompt is active. What I would like is to have some way for ProgressProc to check if the main thread (really, any other thread) is suspended in pdb and then I can skip markProgress().
There's sys.gettrace(), but that only works for the thread that did the pdb.set_trace() and I can't figure out how to call it on a different thread than the one I'm in. What else can I do? Are there any signals I can catch? I could have my main method replace pdb.set_trace to call some multiprocessing.Event first. Is there any cleaner way?
ETA: This is also for a python gdb command.