diff options
| author | Fuwn <[email protected]> | 2023-03-29 00:43:39 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-03-29 00:43:39 -0700 |
| commit | 84a57bd8c08374f48ac0d0f8837ba4958b0789d2 (patch) | |
| tree | 43f49ddde40e6a2c7dc5a7c0e993ad599254f968 /src | |
| parent | feat(uptime): query string to query key value pair (diff) | |
| download | locus-84a57bd8c08374f48ac0d0f8837ba4958b0789d2.tar.xz locus-84a57bd8c08374f48ac0d0f8837ba4958b0789d2.zip | |
fix(stocks): 0.10.10 <- 0.11.10 to fix tokio thread panic
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/stocks.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/modules/stocks.rs b/src/modules/stocks.rs index 33beeb8..bc07f71 100644 --- a/src/modules/stocks.rs +++ b/src/modules/stocks.rs @@ -75,12 +75,15 @@ impl Quote { fn symbol_to_string(symbol: &str) -> String { let mut quote = None; - if let Ok(response) = reqwest::blocking::get(format!( - "https://finnhub.io/api/v1/quote?symbol={}&token={}", - symbol, - std::env::var("FINNHUB_TOKEN") - .expect("could not locate FINNHUB_TOKEN environment variable") - )) { + // https://github.com/seanmonstar/reqwest/issues/1017#issuecomment-1157260218 + if let Ok(response) = tokio::task::block_in_place(|| { + reqwest::blocking::get(&format!( + "https://finnhub.io/api/v1/quote?symbol={}&token={}", + symbol, + std::env::var("FINNHUB_TOKEN") + .expect("could not locate FINNHUB_TOKEN environment variable") + )) + }) { if let Ok(response_content) = response.json::<Quote>() { if response_content.dp.is_some() { quote = Some(response_content); |