usar 50 coroutinas en coto

This commit is contained in:
Cat /dev/Nulo 2024-08-19 20:47:33 -03:00
parent 5943d80252
commit adf1d7ac59
2 changed files with 13 additions and 6 deletions

View file

@ -1,3 +1,5 @@
use std::env;
use super::now_sec;
use super::AutoArgs;
use super::AutoTelegram;
@ -61,7 +63,16 @@ impl Auto {
// }
{
let t0 = now_sec();
let counters = self.scraper.fetch_list(&self.db, links).await;
let n_coroutines = if supermercado == Supermercado::Coto {
50
} else {
env::var("N_COROUTINES")
.map_or(Ok(24), |s| s.parse::<usize>())
.expect("N_COROUTINES no es un número")
};
let counters = self.scraper.fetch_list(&self.db, links, n_coroutines).await;
self.inform(&format!(
"Downloaded {:?}: {:?} (took {})",
&supermercado,

View file

@ -128,11 +128,7 @@ impl Scraper {
counters
}
pub async fn fetch_list(&self, db: &Db, links: Vec<String>) -> Counters {
let n_coroutines = env::var("N_COROUTINES")
.map_or(Ok(24), |s| s.parse::<usize>())
.expect("N_COROUTINES no es un número");
pub async fn fetch_list(&self, db: &Db, links: Vec<String>, n_coroutines: usize) -> Counters {
stream::iter(links)
.map(|url| {
let db = db.clone();