-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Future is no longer Send #206
Comments
This is not a problem, since |
use tokio::spawn;
fn main() {
spawn(worker());
}
async fn worker() {
let html = reqwest::get("https://www.rust-lang.org").await.unwrap();
let html = html.text().await.unwrap();
let document = scraper::Html::parse_document(&html);
let selector = scraper::Selector::parse("a").unwrap();
for element in document.select(&selector) {
let html = reqwest::get("https://www.rust-lang.org").await.unwrap();
let html = html.text().await.unwrap();
let document = scraper::Html::parse_document(&html);
}
} this is the code to recreate this, is your comment and advice for the user of the lib or for the fix? |
The problem is that you are holding on to async fn worker() {
let html = reqwest::get("https://www.rust-lang.org").await.unwrap();
let html = html.text().await.unwrap();
let links = {
let document = scraper::Html::parse_document(&html);
let selector = scraper::Selector::parse("a").unwrap();
document.select(&selector).map(|element| element.attr("href").unwrap().to_owned()).collect::<Vec<_>>()
};
for href in links {
let html = reqwest::get(href).await.unwrap();
let html = html.text().await.unwrap();
let document = scraper::Html::parse_document(&html);
}
} |
yes i recognized that, but i was under the impression that the atomic feature would just allow me to use it over async calls |
Well, it allows you to keep it alive, thereby possibly sending it to other threads (after resuming after a suspension point). But you are essentially holding a |
the issue in #181 is no longer fixable with the feature "atomic"
using scraper 0.19 / 0.20 has the same result
The text was updated successfully, but these errors were encountered: