let mut urls = handled_urls.lock().unwrap();
if !urls.contains(&child_url) {
println!("hadl_urls.size() is {}", hadl_urls.len());
urls.insert(child_url.clone());
drop(urls);
tokio::spawn(handle_url(child_url, handled_urls.clone())).await;
}
Compiler thinks that urls outlives the tokio::spawn(handle_url(child_url, handled_urls.clone())).await; ...
But as we can see, there is happens drop of this object before call of tokio::spawn ...
Is it an issue in compiler or maybe I do not understand something ?
One way this could fail: if the function calling tokio::spawn is in one half of a select! and it finishes, the task waiting for the spawn is aborted without aborting the spawned task, invalidating the url.