Hi all,
I have a reduced version of a program here, that builds fine.
However, when I try to run it, using cargo run
or building and then executing from the command line, the debug build comes back with
error: could not execute process `target\debug\p16_fake_search_select.exe` (never executed)
Caused by:
Access is denied. (os error 5)
or a variant of that (this example is from cargo run
) . Furthermore, at the moment of calling the exe, it is removed (!) from the file system.
A release build works as expected.
The same .exe files on another PC have the same behaviour. BTW: I am on W10 machines.
And it all runs fine in the Playground.
This is the code. If you comment in the line //let period = 100;
both debug and release builds run fine.
use rand::prelude::*;
// These crates need dependencies in Cargol.toml
use tokio::sync::mpsc; // oneshot; // , mpsc, oneshot};
use tokio::time::{sleep, Duration};
type Rslt = String;
#[tokio::main]
async fn main() {
let results = google("golang").await;
println!("Results: {:?}", results);
}
// Two other versions of this fake searcher have been deleted for isolating the bug
async fn video(query: String) -> Rslt {
let period = thread_rng().gen_range(0..=100);
//let period = 100;
sleep(Duration::from_millis(period)).await;
format!("{} result for {}", "Video", query)
}
async fn google(query: &str) -> Vec<Rslt> {
let query = query.to_string();
let (tx0, mut rx) = mpsc::channel::<String>(1);
// Spawning 2 other similar processes has been deleted for isolating the bug
tokio::spawn(async move { tx0.send(video(query).await).await.unwrap(); });
let mut result = Vec::new();
// The original tokio::select! has been deleted for isolating the bug
while let Some(msg) = rx.recv().await {
result.push(msg);
}
result
}
Anyone have a clue what's going on here?