Don't create a thread if stderr_stream is None (#11421)

# Description

There is no need to create a thread if `stderr_stream` is `None`.
This commit is contained in:
nibon7 2023-12-25 22:10:15 +08:00 committed by GitHub
parent 913c2b8d1c
commit 534287ed65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -861,10 +861,13 @@ pub fn print_if_stream(
// NOTE: currently we don't need anything from stderr
// so we just consume and throw away `stderr_stream` to make sure the pipe doesn't fill up
thread::Builder::new()
.name("stderr consumer".to_string())
.spawn(move || stderr_stream.map(|x| x.into_bytes()))
.expect("could not create thread");
if let Some(stderr_stream) = stderr_stream {
thread::Builder::new()
.name("stderr consumer".to_string())
.spawn(move || stderr_stream.into_bytes())
.expect("could not create thread");
}
if let Some(stream) = stream {
for s in stream {
let s_live = s?;