Hi, I want to get a futures::Stream for the output of a std::process::Command.
But my implementation so far blocks after the first call to poll_next() (which returns Poll::Pending).
My (limited) understanding of the async world is that the executor (tokio::main) should retry calling poll_next().
If no data is available for reading, the method returns Poll::Pending and arranges for the current task (via cx.waker().wake_by_ref() ) to receive a notification when the object becomes readable or is closed.
Adding
cx.waker().wake_by_ref();
before you return Poll::Pending makes your code complete running. You can check the async book for more info about wakers and other async stuff.
Oh, I looked into tokio::process::Command, and apparently didn't look far enough. I was surprised that the "output()" Future returns a Vec instead of something streaming the result. Following the documentation further to tokio::process::ChildStdout, I see the poll_read() method I was missing.
Thanks!