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","."]
code: def _watch_process(cls, selfref, process, state, q):
      r = repr(selfref())
      process.join()
      exitcode = original_exit_code = process.exitcode
      if exitcode is None:
          # The child process is already reaped
          # (may happen if waitpid() is called elsewhere).
          exitcode = 255
      state.is_alive = False
      state.exitcode = exitcode
      # Make sure the process is removed from the global list
      # (see _children in multiprocessing/process.py)
      # Then notify the Process object
      self = selfref()  # only keep self alive when required
      try:
          if self is not None:
              _loop_add_callback(self._loop, self._on_exit, exitcode)
      finally:
          self = None  # lose reference
  
      # logging may fail - defer calls to after the callback is added
      if original_exit_code is None:
          logger.warning(
              "[%s] process %r exit status was already read will report exitcode 255",
              r,
              state.pid,
          )
      else:
          logger.debug(
              "[%s] process %r exited with code %r",
              r,
              state.pid,
              exitcode,
          )
  
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 9 for calling the AsyncProcess obj's underlying member method code with example usage: obj._watch_process(cls, ref, process, state, q) without return types