aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/stocks.rs15
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);