Skip to content

Commit 7d8c005

Browse files
committed
don't lock queue after panics or when retreiving the lock fails
1 parent 5a19ca2 commit 7d8c005

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/utils/queue_builder.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{docbuilder::RustwideBuilder, utils::report_error, BuildQueue};
2-
use anyhow::Error;
2+
use anyhow::{Context, Error};
33
use log::{debug, error, warn};
44
use std::panic::{catch_unwind, AssertUnwindSafe};
55
use std::sync::Arc;
@@ -18,10 +18,18 @@ pub fn queue_builder(
1818
}
1919

2020
// check lock file
21-
if build_queue.is_locked()? {
22-
warn!("Build queue is locked, skipping building new crates");
23-
thread::sleep(Duration::from_secs(60));
24-
continue;
21+
match build_queue.is_locked().context("could not get queue lock") {
22+
Ok(true) => {
23+
warn!("Build queue is locked, skipping building new crates");
24+
thread::sleep(Duration::from_secs(60));
25+
continue;
26+
}
27+
Ok(false) => {}
28+
Err(err) => {
29+
report_error(&err);
30+
thread::sleep(Duration::from_secs(60));
31+
continue;
32+
}
2533
}
2634

2735
// If a panic occurs while building a crate, lock the queue until an admin has a chance to look at it.
@@ -41,8 +49,8 @@ pub fn queue_builder(
4149

4250
if let Err(e) = res {
4351
error!("GRAVE ERROR Building new crates panicked: {:?}", e);
44-
// If we panic here something is really truly wrong and trying to handle the error won't help.
45-
build_queue.lock().expect("failed to lock queue");
52+
thread::sleep(Duration::from_secs(60));
53+
continue;
4654
}
4755
}
4856
}

0 commit comments

Comments
 (0)