-
|
I am using a pipe target and a stream to read from stdout. Do I need to keep reading from the stream until done, or cancelled, or can I return early when I found the data I was looking for? E.g. PipeTarget stdOutTarget = PipeTarget.Create(
async (stream, cancellationToken) =>
{
// Read the stream
Utf8JsonAsyncStreamReader jsonStreamReader = new(stream);
while (await jsonStreamReader.ReadAsync(cancellationToken))
{ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
You can return early, but then the pipe will be closed -- CliWrap will not finish draining the data for you, but the process will also not be able to write any more data either. This is exactly how https://github.com/Tyrrrz/CliWrap#:~:text=Warning%3A%20Using%20PipeTarget,Stream.Null). Generally it should be fine, but whether the process will be able to complete successfully depends on the program you're running. You won't get a deadlock though. |
Beta Was this translation helpful? Give feedback.

You can return early, but then the pipe will be closed -- CliWrap will not finish draining the data for you, but the process will also not be able to write any more data either. This is exactly how
PipeTarget.Nullworks, so the warning in the readme applies here:https://github.com/Tyrrrz/CliWrap#:~:text=Warning%3A%20Using%20PipeTarget,Stream.Null).
Generally it should be fine, but whether the process will be able to complete successfully depends on the program you're running. You won't get a deadlock though.