There are two answers here:
One is that writing the stream does not imply the data is immediately
readable, or will even be split up the same when received. The second part,
is that Julia does not start consuming the data until you start reading it.
This is important because you might want to pass this handle to an external
process, and not have Julia consume part of the data I the meantime.

On Sunday, September 14, 2014, Dan Luu <dan...@gmail.com> wrote:

> julia> r,_ = redirect_stdout()
> (Pipe(open, 0 bytes waiting),Pipe(open, 0 bytes waiting))
> julia> nb_available(r)
> 0
> julia> println("foo")
> julia> nb_available(r)
> 0
> julia> println("foo")
> julia> nb_available(r)
> 0
> julia> readline(r)
> "foo\n"
> julia> nb_available(r)
> 4
>
> Even if there's data available, nb_available returns 0. From the name,
> I would have expected this function to return the number of bytes
> available. However, since there's no documentation, either in
> help(nb_available) or in the code itself, I can't tell if this is a
> bug or if this is behavior is by design.
>

Reply via email to