mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:10:09 +00:00
Lock stdout
once when printing diagnostics (#1901)
https://doc.rust-lang.org/stable/std/io/struct.Stdout.html > Each handle shares a global buffer of data to be written to the standard output stream. > Access is also synchronized via a lock and > explicit control over locking is available via the [`lock`](https://doc.rust-lang.org/stable/std/io/struct.Stdout.html#method.lock) method.
This commit is contained in:
parent
d71a615b18
commit
cb4f305ced
1 changed files with 3 additions and 3 deletions
|
@ -122,7 +122,7 @@ impl<'a> Printer<'a> {
|
|||
}
|
||||
|
||||
if matches!(self.violations, Violations::Hide) {
|
||||
let mut stdout = BufWriter::new(io::stdout());
|
||||
let mut stdout = BufWriter::new(io::stdout().lock());
|
||||
if matches!(
|
||||
self.format,
|
||||
SerializationFormat::Text | SerializationFormat::Grouped
|
||||
|
@ -132,7 +132,7 @@ impl<'a> Printer<'a> {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
let mut stdout = BufWriter::new(io::stdout());
|
||||
let mut stdout = BufWriter::new(io::stdout().lock());
|
||||
match self.format {
|
||||
SerializationFormat::Json => {
|
||||
writeln!(
|
||||
|
@ -312,7 +312,7 @@ impl<'a> Printer<'a> {
|
|||
);
|
||||
}
|
||||
|
||||
let mut stdout = BufWriter::new(io::stdout());
|
||||
let mut stdout = BufWriter::new(io::stdout().lock());
|
||||
if !diagnostics.messages.is_empty() {
|
||||
if self.log_level >= &LogLevel::Default {
|
||||
writeln!(stdout)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue