code: def kill(self, sig=signal.SIGTERM):
          
          while self.is_alive():
              self.killed = True
              time.sleep(POLLING_DELAY) # "Was a process spawned?" polling
              if not self.spawned:
                  continue # Either self.run returns or runner yields
              if self.process.poll() is None: # It's running
                  self.process.send_signal(sig)
                  try: # There's no os.WNOHANG in Windows
                      os.waitpid(self.process.pid, getattr(os, "WNOHANG", 1))
                  except OSError: # Ignore "No child processes" error
                      pass
              break # We already either killed or finished it
          self.join()
docs: Terminate the test job.
  
          Kill the subprocess if it was spawned, abort the spawning
          process otherwise. This information can be collected afterwards
          by reading the self.killed and self.spawned flags.
  
          Also join the 3 related threads to the caller thread. This can
          be safely called from any thread.
  
          This method behaves as self.join() when the thread isn't alive,
          i.e., it doesn't raise an exception.
  
          The ``sig`` parameter should be either:
  
          * ``signal.SIGKILL`` (``9``), on Linux or OSX;
          * ``signal.SIGTERM`` (``15``), the default value. On Windows
            this one calls the ``TerminateProcess`` Win32 API function.