Introduction¶
A library to help with atomic processing of lines. Some libraries are a bit fuzzy on what happens if a call
to readline
times out (is the partial read data consumed? Is a partial read returned?). This can be used
as an adapter for such libraries as long as they have an ordinary read
call.
Overview¶
The AtomicLineReader provides a sane readline
function internally. LineProcessor extends this by running an AtomicLineReader][atomiclines.atomiclinereader.AtomicLineReader] and then running any user provided processing function on each line.
The library is implemented as async.
Example¶
Assume you would like to do read lines from the serial port asynchronously.
Note
Accoridng to my best knowledge cross platform async access to the serial port is hard, and is the reason why this was created (and for me to have a proper play with async ;) )
- We just print every line, like a terminal
- I am a strong believer in preventing users from forgetting to do cleanup through the use of contextmanagers. Otherwise cleanup might be ommitted, like the closing of the AioSerial port in this example.
- A command which the serial counterpart hopefully understands