Skip to content

Commit

Permalink
GH-56 - Attempt to fix the "would block" resource error
Browse files Browse the repository at this point in the history
Per rwf2/Rocket#243, attempting to
fix this by jacking up the number of workers. Once async is done, this
shouldn't be needed.
  • Loading branch information
ZNielsen committed Apr 26, 2021
1 parent 4158b11 commit d48e235
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
1 change: 1 addition & 0 deletions Rocket.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[global]
workers=128
template_dir = "server/web/templates/"
#template_dir = "server/templates/"

Expand Down
16 changes: 2 additions & 14 deletions server/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ pub fn list_feeds_handler(config: State<RocketConfig>) -> Result<String, String>
// RETURN: Our PodRacer RSS file
//
#[get("/podcasts/<podcast>/racer.rss")]
pub fn serve_rss_handler(config: State<RocketConfig>, podcast: String) -> Option<File> {
pub fn serve_rss_handler(config: State<RocketConfig>, podcast: String) -> Result<File, std::io::Error> {
println!("Serving at {}", chrono::Utc::now().to_rfc3339());
// Serve the rss file
let path: PathBuf = [
Expand All @@ -299,19 +299,7 @@ pub fn serve_rss_handler(config: State<RocketConfig>, podcast: String) -> Option
.iter()
.collect();
println!("Getting podcast from path: {:?}", path);
// Try a couple times to get the file
for _ in 0..5 {
match std::fs::File::open(&path) {
Ok(file) => return Some(file),
Err(e) => {
println!("Got error: {}", e);
println!("Retrying...");
let backoff = std::time::Duration::from_millis(300);
std::thread::sleep(backoff);
},
}
}
None
std::fs::File::open(&path)
}

//
Expand Down
4 changes: 2 additions & 2 deletions target/armv7-unknown-linux-gnueabihf/release/podracer
Git LFS file not shown

0 comments on commit d48e235

Please sign in to comment.