class_docstr: Manage the background execution of callbacks with subprocesses and a diskcache result backend.
class_docstr_tok: ["Manage","the","background","execution","of","callbacks","with","subprocesses","and","a","diskcache","result","backend","."]
code: def terminate_job(self, job):
      import psutil  # pylint: disable=import-outside-toplevel,import-error
  
      if job is None:
          return
  
      job = int(job)
  
      # Use diskcache transaction so multiple process don't try to kill the
      # process at the same time
      with self.handle.transact():
          if psutil.pid_exists(job):
              process = psutil.Process(job)
  
              for proc in process.children(recursive=True):
                  try:
                      proc.kill()
                  except psutil.NoSuchProcess:
                      pass
  
              try:
                  process.kill()
              except psutil.NoSuchProcess:
                  pass
  
              try:
                  process.wait(1)
              except (psutil.TimeoutExpired, psutil.NoSuchProcess):
                  pass
  
imports: import traceback
  from contextvars import copy_context
  from .None import BaseLongCallbackManager
  from ..._callback_context import context_value
  from ..._utils import AttributeDict
  from ...exceptions import PreventUpdate
label_desc: Use image node_id 2 for calling the DiskcacheManager obj's underlying member method code with example usage: obj.terminate_job(job) without return types