class_docstr: Container for a running subprocess. Supports communication with the
  subprocess via stdin and stdout.
class_docstr_tok: ["Container","for","a","running","subprocess",".","Supports","communication","with","the","subprocess","via","stdin","and","stdout","."]
docstr: Get a single stdout line from the generator.
  
  If timeout was specified, and exception_on_timeout is False,
  and if a timeout occurs, return None. Otherwise, return the
  string that was read from the generator.
code: def get_one_line(self) -> Optional[str]:
      """
      Get a single stdout line from the generator.
  
      If timeout was specified, and exception_on_timeout is False,
      and if a timeout occurs, return None. Otherwise, return the
      string that was read from the generator.
      """
  
      # Implementation remarks:
      # 1. We know that BatchedCommandProtocol only returns complete lines on
      #    stdout, that makes this code simple.
      # 2. stderr is handled transparently within this method,
      #    by adding all stderr-content to an internal buffer.
      while True:
          source, data = self.generator.send(None)
          if source == STDERR_FILENO:
              self.stderr_output += data
          elif source == STDOUT_FILENO:
              return data
          elif source == "timeout":
              # TODO: we should restart the subprocess on timeout, otherwise
              #  we might end up with results from a previous instruction,
              #  when handling multiple instructions at once. Until this is
              #  done properly, communication timeouts are ignored in order
              #  to avoid errors.
              if data is None:
                  lgr.debug("BatchedCommand: timeout on process")
              else:
                  lgr.debug(
                      "BatchedCommand: timeout on file descriptor %d",
                      data,
                  )
          else:
              raise ValueError(f"{self}: unknown source: {source}")
  
imports: from __future__ import annotations
  import logging
  import os
  import queue
  import sys
  import warnings
  from datetime import datetime
  from operator import attrgetter
  from queue import Queue
  from subprocess import TimeoutExpired
  from typing import Any, Callable, List, Optional, Tuple, Union
  from weakref import ReferenceType, WeakValueDictionary, ref
  from datalad import cfg
  from datalad.runner.coreprotocols import KillOutput, NoCapture, StdErrCapture, StdOutCapture, StdOutErrCapture
  from datalad.runner.gitrunner import GIT_SSH_COMMAND, GitRunnerBase, GitWitlessRunner
  from datalad.runner.nonasyncrunner import STDERR_FILENO, STDOUT_FILENO, _ResultGenerator, run_command
  from datalad.runner.protocol import GeneratorMixIn, WitlessProtocol
  from datalad.runner.runner import WitlessRunner
  from datalad.runner.utils import LineSplitter
  from datalad.support.exceptions import CommandError
  from datalad.utils import auto_repr, ensure_unicode
label_desc: Use image node_id 8 for calling the BatchedCommand obj's underlying member method code with example usage: obj.get_one_line() and returns: data