class_docstr: Run tests in a subprocess
      
class_docstr_tok: ["Run","tests","in","a","subprocess"]
docstr: Cleanup on exit by killing any leftover processes.
code: def cleanup_process(self):
      """Cleanup on exit by killing any leftover processes."""
      subp = self.process
      if subp is None or (subp.poll() is not None):
          return  # Process doesn't exist, or is already dead.
  
      try:
          print("Cleaning up stale PID: %d" % subp.pid)
          subp.kill()
      except:  # (OSError, WindowsError) ?
          # This is just a best effort, if we fail or the process was
          # really gone, ignore it.
          pass
      else:
          for i in range(10):
              if subp.poll() is None:
                  time.sleep(0.1)
              else:
                  break
  
      if subp.poll() is None:
          # The process did not die...
          print("... failed. Manual cleanup may be required.")
  
imports: from __future__ import print_function
  import argparse
  import json
  import multiprocessing.pool
  import os
  import stat
  import re
  import requests
  import shutil
  import signal
  import sys
  import subprocess
  import time
  from .iptest import have, test_group_names, test_sections, StreamCapturer, test_for
  from IPython.utils.path import compress_user
  from IPython.utils.py3compat import bytes_to_str
  from IPython.utils.sysinfo import get_sys_info
  from IPython.utils.tempdir import TemporaryDirectory
  from IPython.utils.text import strip_ansi
label_desc: Use image node_id 6 for calling the TestController obj's underlying member method code with example usage: obj.cleanup_process() without return types