code: def managed_process(process):
      
      try:
          yield process
      finally:
          for stream in [process.stdout, process.stdin, process.stderr]:
              if stream:
                  stream.close()
          process.wait()
docs: Wrapper for subprocess.Popen to work across various Python versions, when using the with syntax.