stream_as_generator¶
- async lsst.ts.salobj.stream_as_generator(stream: TextIO, encoding: str = 'utf-8') AsyncGenerator[str, None] ¶
Await lines of text from stdin or another input stream.
Example usage:
- async for line in stream_as_generator(stream=sys.stdin):
print(f”read {repr(line)}”)
- Parameters
- Returns
- line
str
A line of data, optionally decoded.
- line
Notes
Thanks to http://blog.mathieu-leplatre.info/some-python-3-asyncio-snippets.html