class_docstr: Wraps ``subprocess.Popen`` with IOStream support.
  
  The constructor is the same as ``subprocess.Popen`` with the following
  additions:
  
  * ``stdin``, ``stdout``, and ``stderr`` may have the value
    ``tornado.process.Subprocess.STREAM``, which will make the corresponding
    attribute of the resulting Subprocess a `.PipeIOStream`. If this option
    is used, the caller is responsible for closing the streams when done
    with them.
  
  The ``Subprocess.STREAM`` option and the ``set_exit_callback`` and
  ``wait_for_exit`` methods do not work on Windows. There is
  therefore no reason to use this class instead of
  ``subprocess.Popen`` on that platform.
  
  .. versionchanged:: 5.0
     The ``io_loop`` argument (deprecated since version 4.1) has been removed.
class_docstr_tok: ["Wraps","``","subprocess.Popen","``","with","IOStream","support",".","The","constructor","is","the","same","as","``","subprocess.Popen","``","with","the","following","additions",":","*","``","stdin","``",",","``","stdout","``",",","and","``","stderr","``","may","have","the","value","``","tornado.process.Subprocess.STREAM","``",",","which","will","make","the","corresponding","attribute","of","the","resulting","Subprocess","a","`",".PipeIOStream","`",".","If","this","option","is","used",",","the","caller","is","responsible","for","closing","the","streams","when","done","with","them",".","The","``","Subprocess.STREAM","``","option","and","the","``","set_exit_callback","``","and","``","wait_for_exit","``","methods","do","not","work","on","Windows",".","There","is","therefore","no","reason","to","use","this","class","instead","of","``","subprocess.Popen","``","on","that","platform",".","..","versionchanged",":",":","5.0","The","``","io_loop","``","argument","(","deprecated","since","version","4.1",")","has","been","removed","."]
docstr: Returns a `.Future` which resolves when the process exits.
  
  Usage::
  
      ret = yield proc.wait_for_exit()
  
  This is a coroutine-friendly alternative to `set_exit_callback`
  (and a replacement for the blocking `subprocess.Popen.wait`).
  
  By default, raises `subprocess.CalledProcessError` if the process
  has a non-zero exit status. Use ``wait_for_exit(raise_error=False)``
  to suppress this behavior and return the exit status without raising.
  
  .. versionadded:: 4.2
  
  Availability: Unix
docstr_tok: ["Returns","a","`",".Future","`","which","resolves","when","the","process","exits",".","Usage",":",":","ret","=","yield","proc.wait_for_exit","(",")","This","is","a","coroutine-friendly","alternative","to","`","set_exit_callback","`","(","and","a","replacement","for","the","blocking","`","subprocess.Popen.wait","`",")",".","By","default",",","raises","`","subprocess.CalledProcessError","`","if","the","process","has","a","non-zero","exit","status",".","Use","``","wait_for_exit","(","raise_error=False",")","``","to","suppress","this","behavior","and","return","the","exit","status","without","raising",".","..","versionadded",":",":","4.2","Availability",":","Unix"]
code: def wait_for_exit(self, raise_error: bool = True) -> "Future[int]":
      """Returns a `.Future` which resolves when the process exits.
  
      Usage::
  
          ret = yield proc.wait_for_exit()
  
      This is a coroutine-friendly alternative to `set_exit_callback`
      (and a replacement for the blocking `subprocess.Popen.wait`).
  
      By default, raises `subprocess.CalledProcessError` if the process
      has a non-zero exit status. Use ``wait_for_exit(raise_error=False)``
      to suppress this behavior and return the exit status without raising.
  
      .. versionadded:: 4.2
  
      Availability: Unix
      """
      future = Future()  # type: Future[int]
  
      def callback(ret: int) -> None:
          if ret != 0 and raise_error:
              # Unfortunately we don't have the original args any more.
              future_set_exception_unless_cancelled(
                  future, CalledProcessError(ret, "unknown")
              )
          else:
              future_set_result_unless_cancelled(future, ret)
  
      self.set_exit_callback(callback)
      return future
  
imports: import asyncio
  import os
  import multiprocessing
  import signal
  import subprocess
  import sys
  import time
  from binascii import hexlify
  from tornado.concurrent import Future, future_set_result_unless_cancelled, future_set_exception_unless_cancelled
  from tornado import ioloop
  from tornado.iostream import PipeIOStream
  from tornado.log import gen_log
  import typing
  from typing import Optional, Any, Callable
label_desc: Use image node_id 3 for calling the Subprocess obj's underlying member method code with example usage: obj.wait_for_exit(raise_error) and returns: future