code: def __init__(
      self,
      cmd,
      timeout=30,
      maxread=2000,
      searchwindowsize=None,
      logfile=None,
      cwd=None,
      env=None,
      encoding=None,
      codec_errors="strict",
      preexec_fn=None,
  ):
      super(PopenSpawn, self).__init__(
          timeout=timeout,
          maxread=maxread,
          searchwindowsize=searchwindowsize,
          logfile=logfile,
          encoding=encoding,
          codec_errors=codec_errors,
      )
  
      # Note that `SpawnBase` initializes `self.crlf` to `\r\n`
      # because the default behaviour for a PTY is to convert
      # incoming LF to `\r\n` (see the `onlcr` flag and
      # https://stackoverflow.com/a/35887657/5397009). Here we set
      # it to `os.linesep` because that is what the spawned
      # application outputs by default and `popen` doesn't translate
      # anything.
      if encoding is None:
          self.crlf = os.linesep.encode("ascii")
      else:
          self.crlf = self.string_type(os.linesep)
  
      kwargs = dict(
          bufsize=0,
          stdin=subprocess.PIPE,
          stderr=subprocess.STDOUT,
          stdout=subprocess.PIPE,
          cwd=cwd,
          preexec_fn=preexec_fn,
          env=env,
      )
  
      if sys.platform == "win32":
          startupinfo = subprocess.STARTUPINFO()
          startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
          kwargs["startupinfo"] = startupinfo
          kwargs["creationflags"] = subprocess.CREATE_NEW_PROCESS_GROUP
  
      if isinstance(cmd, string_types) and sys.platform != "win32":
          cmd = shlex.split(cmd, posix=os.name == "posix")
  
      self.proc = subprocess.Popen(cmd, **kwargs)
      self.pid = self.proc.pid
      self.closed = False
      self._buf = self.string_type()
  
      self._read_queue = Queue()
      self._read_thread = threading.Thread(target=self._read_incoming)
      self._read_thread.daemon = True
      self._read_thread.start()
  
imports: import os
  import threading
  import subprocess
  import sys
  import time
  import signal
  import shlex
  from .spawnbase import SpawnBase, PY3
  from .exceptions import EOF
  from .utils import string_types
label_desc: Use image node_id 1 to create a new PopenSpawn object from inherited base classes: SpawnBase with example: obj = PopenSpawn(cmd, timeout, maxread, searchwindowsize, logfile, cwd, env, encoding, codec_errors, preexec_fn)