title: Find reason for sleeping python process
body: <p>I have a unittest that does a bunch of stuff in several different threads. When I stop everything in the tearDown method, somehow something is still running. And by running I mean sleeping. I ran the top command on the python process (Ubuntu 12.04), which told me that the process was sleeping.</p>
  
  <p>Now I have tried using pdb to figure out what is going on, e.g. by putting set_trace() at the end of tearDown. But that tells me nothing. I suspect this is because some other thread has started sleeping earlier and is therefore not accessed anymore at this point.</p>
  
  <p>Is there any tool or method I can use to track down the cause of my non-stopping process?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Using <code>ps -Tp &lt;#Process> -o wchan</code> I now know that 4 threads are still running, of which three waiting on <strong>futex_wait_queue_me</strong> and one on <strong>unix_stream_data_wait</strong>. Since I had a subprocess previously, which I killed with <code>os.kill(pid, signal.SIGKILL)</code>, I suspect that the Pipe connection is somehow still waiting for that process. Perhaps the fast mutexes are waiting for that as well.</p>
  
  <p>Is there anyway I could further reduce the search space?</p>