docstr: Make sure that resource tracker process is running.
  
  This can be run from any process.  Usually a child process will use
  the resource created by its parent.
docstr_tok: ["Make","sure","that","resource","tracker","process","is","running",".","This","can","be","run","from","any","process",".","Usually","a","child","process","will","use","the","resource","created","by","its","parent","."]
code: def ensure_running(self):
      """Make sure that resource tracker process is running.
  
      This can be run from any process.  Usually a child process will use
      the resource created by its parent."""
      with self._lock:
          if self._fd is not None:
              # resource tracker was launched before, is it still running?
              if self._check_alive():
                  # => still alive
                  return
              # => dead, launch it again
              os.close(self._fd)
              if os.name == "posix":
                  try:
                      # At this point, the resource_tracker process has been
                      # killed or crashed. Let's remove the process entry
                      # from the process table to avoid zombie processes.
                      os.waitpid(self._pid, 0)
                  except OSError:
                      # The process was terminated or is a child from an
                      # ancestor of the current process.
                      pass
              self._fd = None
              self._pid = None
  
              warnings.warn(
                  "resource_tracker: process died unexpectedly, "
                  "relaunching.  Some folders/sempahores might "
                  "leak."
              )
  
          fds_to_pass = []
          try:
              fds_to_pass.append(sys.stderr.fileno())
          except Exception:
              pass
  
          r, w = os.pipe()
          if sys.platform == "win32":
              _r = duplicate(msvcrt.get_osfhandle(r), inheritable=True)
              os.close(r)
              r = _r
  
          cmd = f"from {main.__module__} import main; main({r}, {VERBOSE})"
          try:
              fds_to_pass.append(r)
              # process will out live us, so no need to wait on pid
              exe = spawn.get_executable()
              args = [
                  exe,
                  *util._args_from_interpreter_flags(),
                  "-c",
                  cmd,
              ]
              util.debug(f"launching resource tracker: {args}")
              # bpo-33613: Register a signal mask that will block the
              # signals.  This signal mask will be inherited by the child
              # that is going to be spawned and will protect the child from a
              # race condition that can make the child die before it
              # registers signal handlers for SIGINT and SIGTERM. The mask is
              # unregistered after spawning the child.
              try:
                  if _HAVE_SIGMASK:
                      signal.pthread_sigmask(
                          signal.SIG_BLOCK, _IGNORED_SIGNALS
                      )
                  pid = spawnv_passfds(exe, args, fds_to_pass)
              finally:
                  if _HAVE_SIGMASK:
                      signal.pthread_sigmask(
                          signal.SIG_UNBLOCK, _IGNORED_SIGNALS
                      )
          except BaseException:
              os.close(w)
              raise
          else:
              self._fd = w
              self._pid = pid
          finally:
              if sys.platform == "win32":
                  _winapi.CloseHandle(r)
              else:
                  os.close(r)
  
file_path: catboost/contrib/python/joblib/joblib/externals/loky/backend/resource_tracker.py
imports: import os
  import shutil
  import sys
  import signal
  import warnings
  import threading
  from _multiprocessing import sem_unlink
  from multiprocessing import util
  from .None import spawn
label_desc: Use image node_id 3 for calling the ResourceTracker obj's underlying member method code with example usage: obj.ensure_running() without return types