stream_as_generator

async lsst.ts.salobj.stream_as_generator(stream: TextIO, exit_str: str = '') AsyncGenerator[str, None]

Await lines of text from stdin or another text input stream.

Example usage:

async for line in stream_as_generator(stream=sys.stdin):

print(f”read {repr(line)}”)

Parameters
streamstream

Stream to read, e.g. sys.stdin.

exit_strstr

Exit if this string is seen. Ignored if blank.

Returns
linestr

A non-empty string that is stripped of leading and trailing whitespace,

, and
.