You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rust newb here. I'm assuming I'm doing something wrong but I cant figure it out.
I created a minimal repro with the error below:
#[tokio::main]
async fn main() -> Result<(),()> {
let max_async_threads = 1;
let mut fqdns = Vec::<String>::new();
while fqdns.len() < 2 {
fqdns.push("google.com.".to_string());
}
let mut join_set = JoinSet::<(String)>::new();
for fqdn in fqdns {
while join_set.len() >= max_async_threads {
let result = join_set.join_next().await.expect("Async to return").expect("DNS to resolve");
println!("{}", result);
}
join_set.spawn(some_async(fqdn));
}
while let Some(result) = join_set.join_next().await {
let address = result.expect("DNS to return");
println!("{}", address);
}
Ok(())
}
async fn some_async(fqdn: String) -> String {
let resolver: Resolver = Resolver::new(ResolverConfig::default(), ResolverOpts::default()).unwrap();
let response: Ipv4Lookup = resolver.ipv4_lookup(fqdn).unwrap();
let address = response.iter().next().expect("no addresses returned!");
address.to_string()
}
thread 'thread 'tokio-runtime-workertokio-runtime-worker' panicked at ' panicked at C:\Users\kytravel\.cargo\registry\src\index.crates.io-6f17d22bba15001f\hickory-resolver-0.24.0\src\resolver.rsC:\Users\kytravel\.cargo\registry\src\index.crates.io-6f17d22bba15001f\hickory-resolver-0.24.0\src\resolver.rs::149149::55:
:
Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.
The text was updated successfully, but these errors were encountered:
Rust newb here. I'm assuming I'm doing something wrong but I cant figure it out.
I created a minimal repro with the error below:
The text was updated successfully, but these errors were encountered: