title: Python pdb for a background process
body: <p>I have a python process, spawning multiple background processes. I am currently seeing one/many of the background process get stuck in deadloop or they are becoming irresponsive. </p>
  
  <p>I want to attach a debugger to the background process. So, I can figure out what is going wrong. I have registered a signal handler for my background process (SIGUSR1) which I sets pdb trace. </p>
  
  <p>I am sending the signal from another console to the background process, whenever it hangs.  However, I don't see any terminal which can help me debug the code. </p>
  
  <p>Am I doing something wrong? or is there a better way to attach a debugger to background python process. </p>
  
  <p>I am running on MAC and so using gdb is not straight forward. </p>
  
  <pre><code>  def installHandlers():
      signal.signal(signal.SIGUSR1,debugHandle)
  
     def debugHandle(sig,frame):                                                          
       global processLog
       processLog.info("got the SIGUSR1")                                               
       import pdb                                                                       
       pdb.Pdb().set_trace(frame) 
     </code></pre>
  
  <p>-Thanks</p>