class_docstr: Execute a child program in a new process.
  
  For a complete description of the arguments see the Python documentation.
  
  Arguments:
    args: A string, or a sequence of program arguments.
  
    bufsize: supplied as the buffering argument to the open() function when
        creating the stdin/stdout/stderr pipe file objects
  
    executable: A replacement program to execute.
  
    stdin, stdout and stderr: These specify the executed programs' standard
        input, standard output and standard error file handles, respectively.
  
    preexec_fn: (POSIX only) An object to be called in the child process
        just before the child is executed.
  
    close_fds: Controls closing or inheriting of file descriptors.
  
    shell: If true, the command will be executed through the shell.
  
    cwd: Sets the current directory before the child is executed.
  
    env: Defines the environment variables for the new process.
  
    text: If true, decode stdin, stdout and stderr using the given encoding
        (if set) or the system default otherwise.
  
    universal_newlines: Alias of text, provided for backwards compatibility.
  
    startupinfo and creationflags (Windows only)
  
    restore_signals (POSIX only)
  
    start_new_session (POSIX only)
  
    process_group (POSIX only)
  
    group (POSIX only)
  
    extra_groups (POSIX only)
  
    user (POSIX only)
  
    umask (POSIX only)
  
    pass_fds (POSIX only)
  
    encoding and errors: Text mode encoding and error handling to use for
        file objects stdin, stdout and stderr.
  
  Attributes:
      stdin, stdout, stderr, pid, returncode
class_docstr_tok: ["Execute","a","child","program","in","a","new","process",".","For","a","complete","description","of","the","arguments","see","the","Python","documentation",".","Arguments",":","args",":","A","string",",","or","a","sequence","of","program","arguments",".","bufsize",":","supplied","as","the","buffering","argument","to","the","open","(",")","function","when","creating","the","stdin\/stdout\/stderr","pipe","file","objects","executable",":","A","replacement","program","to","execute",".","stdin",",","stdout","and","stderr",":","These","specify","the","executed","programs","'","standard","input",",","standard","output","and","standard","error","file","handles",",","respectively",".","preexec_fn",":","(","POSIX","only",")","An","object","to","be","called","in","the","child","process","just","before","the","child","is","executed",".","close_fds",":","Controls","closing","or","inheriting","of","file","descriptors",".","shell",":","If","true",",","the","command","will","be","executed","through","the","shell",".","cwd",":","Sets","the","current","directory","before","the","child","is","executed",".","env",":","Defines","the","environment","variables","for","the","new","process",".","text",":","If","true",",","decode","stdin",",","stdout","and","stderr","using","the","given","encoding","(","if","set",")","or","the","system","default","otherwise",".","universal_newlines",":","Alias","of","text",",","provided","for","backwards","compatibility",".","startupinfo","and","creationflags","(","Windows","only",")","restore_signals","(","POSIX","only",")","start_new_session","(","POSIX","only",")","process_group","(","POSIX","only",")","group","(","POSIX","only",")","extra_groups","(","POSIX","only",")","user","(","POSIX","only",")","umask","(","POSIX","only",")","pass_fds","(","POSIX","only",")","encoding","and","errors",":","Text","mode","encoding","and","error","handling","to","use","for","file","objects","stdin",",","stdout","and","stderr",".","Attributes",":","stdin",",","stdout",",","stderr",",","pid",",","returncode"]
docstr: Interact with process: Send data to stdin and close it.
  Read data from stdout and stderr, until end-of-file is
  reached.  Wait for process to terminate.
  
  The optional "input" argument should be data to be sent to the
  child process, or None, if no data should be sent to the child.
  communicate() returns a tuple (stdout, stderr).
  
  By default, all communication is in bytes, and therefore any
  "input" should be bytes, and the (stdout, stderr) will be bytes.
  If in text mode (indicated by self.text_mode), any "input" should
  be a string, and (stdout, stderr) will be strings decoded
  according to locale encoding, or by "encoding" if set. Text mode
  is triggered by setting any of text, encoding, errors or
  universal_newlines.
code: def communicate(self, input=None, timeout=None):
      """Interact with process: Send data to stdin and close it.
      Read data from stdout and stderr, until end-of-file is
      reached.  Wait for process to terminate.
  
      The optional "input" argument should be data to be sent to the
      child process, or None, if no data should be sent to the child.
      communicate() returns a tuple (stdout, stderr).
  
      By default, all communication is in bytes, and therefore any
      "input" should be bytes, and the (stdout, stderr) will be bytes.
      If in text mode (indicated by self.text_mode), any "input" should
      be a string, and (stdout, stderr) will be strings decoded
      according to locale encoding, or by "encoding" if set. Text mode
      is triggered by setting any of text, encoding, errors or
      universal_newlines.
      """
  
      if self._communication_started and input:
          raise ValueError(
              "Cannot send input after starting communication"
          )
  
      # Optimization: If we are not worried about timeouts, we haven't
      # started communicating, and we have one or zero pipes, using select()
      # or threads is unnecessary.
      if (
          timeout is None
          and not self._communication_started
          and [self.stdin, self.stdout, self.stderr].count(None) >= 2
      ):
          stdout = None
          stderr = None
          if self.stdin:
              self._stdin_write(input)
          elif self.stdout:
              stdout = self.stdout.read()
              self.stdout.close()
          elif self.stderr:
              stderr = self.stderr.read()
              self.stderr.close()
          self.wait()
      else:
          if timeout is not None:
              endtime = _time() + timeout
          else:
              endtime = None
  
          try:
              stdout, stderr = self._communicate(
                  input, endtime, timeout
              )
          except KeyboardInterrupt:
              # https://bugs.python.org/issue25942
              # See the detailed comment in .wait().
              if timeout is not None:
                  sigint_timeout = min(
                      self._sigint_wait_secs,
                      self._remaining_time(endtime),
                  )
              else:
                  sigint_timeout = self._sigint_wait_secs
              self._sigint_wait_secs = 0  # nothing else should wait.
              try:
                  self._wait(timeout=sigint_timeout)
              except TimeoutExpired:
                  pass
              raise  # resume the KeyboardInterrupt
  
          finally:
              self._communication_started = True
  
          sts = self.wait(timeout=self._remaining_time(endtime))
  
      return (stdout, stderr)
  
imports: import builtins
  import errno
  import io
  import locale
  import os
  import time
  import signal
  import sys
  import threading
  import warnings
  import contextlib
  from time import monotonic
  import types
label_desc: Use image node_id 11 for calling the Popen obj's underlying member method code with example usage: obj.communicate(input, timeout) and returns: stdout,  stderr