I'm trying to read a line from an io in a non-blocking way.
Unfortunately readline
blocks. I think I can solve this with read_nonblock
with an additional buffer where I store partial result, check if there are multiple lines in the buffer, etc.. but it seems a bit complicated for a simple task like this. Is there a better way to do this?
Note: I'm using event demultiplexing (select
) and I'm quite happy with it, I don't want to create threads, use EventMachine, etc...