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","."]
code: def __init__(self, *args: Any, **kwargs: Any) -> None:
      self.io_loop = ioloop.IOLoop.current()
      # All FDs we create should be closed on error; those in to_close
      # should be closed in the parent process on success.
      pipe_fds = []  # type: List[int]
      to_close = []  # type: List[int]
      if kwargs.get("stdin") is Subprocess.STREAM:
          in_r, in_w = os.pipe()
          kwargs["stdin"] = in_r
          pipe_fds.extend((in_r, in_w))
          to_close.append(in_r)
          self.stdin = PipeIOStream(in_w)
      if kwargs.get("stdout") is Subprocess.STREAM:
          out_r, out_w = os.pipe()
          kwargs["stdout"] = out_w
          pipe_fds.extend((out_r, out_w))
          to_close.append(out_w)
          self.stdout = PipeIOStream(out_r)
      if kwargs.get("stderr") is Subprocess.STREAM:
          err_r, err_w = os.pipe()
          kwargs["stderr"] = err_w
          pipe_fds.extend((err_r, err_w))
          to_close.append(err_w)
          self.stderr = PipeIOStream(err_r)
      try:
          self.proc = subprocess.Popen(*args, **kwargs)
      except:
          for fd in pipe_fds:
              os.close(fd)
          raise
      for fd in to_close:
          os.close(fd)
      self.pid = self.proc.pid
      for attr in ["stdin", "stdout", "stderr"]:
          if not hasattr(self, attr):  # don't clobber streams set above
              setattr(self, attr, getattr(self.proc, attr))
      self._exit_callback = (
          None
      )  # type: Optional[Callable[[int], None]]
      self.returncode = None
  
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 1 to create a new Subprocess object from inherited base classes: object with example: obj = Subprocess()