code: def _patched_process_run(self, *args, **kwargs):
      if not PatchOsFork._current_task:
          return PatchOsFork._original_process_run(
              self, *args, **kwargs
          )
  
      try:
          from ..task import Task
  
          task = Task.current_task()
      except:  # noqa
          task = None
  
      # check if this is Process Pool function
      patched_worker = False
      if hasattr(self, "_target"):
          # Now we have to patch Pool, because pool terminates subprocess directly after
          # the return value of the pool worker function is pushed into the queue,
          # which means it will terminate the process before we finish running our "atexit" call
          try:
              if self._target == pool.worker:  # noqa
                  self._target = partial(
                      PatchOsFork._patched_pool_worker, pool.worker
                  )  # noqa
                  patched_worker = True
          except:  # noqa
              pass
  
      try:
          return PatchOsFork._original_process_run(
              self, *args, **kwargs
          )
      finally:
          if task and patched_worker:
              try:
                  # noinspection PyProtectedMember
                  if task._report_subprocess_enabled:
                      # just in case, remove at exit hooks, we will deadlock when the
                      # main Pool manager will terminate this process, and it will...
                      # noinspection PyProtectedMember
                      task._at_exit_called = True
                  else:
                      # terminate the current Task
                      # noinspection PyProtectedMember
                      task._at_exit()
              except:  # noqa
                  pass
  
imports: import os
  from functools import partial
  from time import sleep
  from multiprocessing import pool
  import six
  from ..config import TASK_LOG_ENVIRONMENT, running_remotely, config
  from ..utilities.process.mp import BackgroundMonitor
label_desc: Use image node_id 3 for calling the PatchOsFork obj's underlying member method code with example usage: obj._patched_process_run() and returns: PatchOsFork, PatchOsFork