class_docstr: A coroutine-compatible multiprocessing.Process-alike.
  All normally blocking methods are wrapped in Tornado coroutines.
class_docstr_tok: ["A","coroutine-compatible","multiprocessing.Process-alike",".","All","normally","blocking","methods","are","wrapped","in","Tornado","coroutines","."]
docstr: Immediately exit the process when parent_alive_pipe is closed.
code: def _immediate_exit_when_closed(cls, parent_alive_pipe):
      """
      Immediately exit the process when parent_alive_pipe is closed.
      """
  
      def monitor_parent():
          try:
              # The parent_alive_pipe should be held open as long as the
              # parent is alive and wants us to stay alive. Nothing writes to
              # it, so the read will block indefinitely.
              parent_alive_pipe.recv()
          except EOFError:
              # Parent process went away unexpectedly. Exit immediately. Could
              # consider other exiting approaches here. My initial preference
              # is to unconditionally and immediately exit. If we're in this
              # state it is possible that a "clean" process exit won't work
              # anyway - if, for example, the system is getting bogged down
              # due to the running out of memory, exiting sooner rather than
              # later might be needed to restore normal system function.
              # If this is in appropriate for your use case, please file a
              # bug.
              os._exit(-1)
          else:
              # If we get here, something odd is going on. File descriptors
              # got crossed?
              raise RuntimeError(
                  "unexpected state: should be unreachable"
              )
  
      t = threading.Thread(target=monitor_parent)
      t.daemon = True
      t.start()
  
imports: from __future__ import annotations
  import asyncio
  import inspect
  import logging
  import multiprocessing
  import os
  import re
  import threading
  import weakref
  from collections.abc import Callable
  from queue import Queue
  from typing import TYPE_CHECKING
  from tornado.concurrent import Future
  from tornado.ioloop import IOLoop
  import dask
  from distributed.utils import get_mp_context, wait_for
label_desc: Use image node_id 6 for calling the AsyncProcess obj's underlying member method code with example usage: obj._immediate_exit_when_closed(cls, parent_alive_pipe) without return types