aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-03-29 00:43:39 -0700
committerFuwn <[email protected]>2023-03-29 00:43:39 -0700
commit84a57bd8c08374f48ac0d0f8837ba4958b0789d2 (patch)
tree43f49ddde40e6a2c7dc5a7c0e993ad599254f968
parentfeat(uptime): query string to query key value pair (diff)
downloadlocus-84a57bd8c08374f48ac0d0f8837ba4958b0789d2.tar.xz
locus-84a57bd8c08374f48ac0d0f8837ba4958b0789d2.zip
fix(stocks): 0.10.10 <- 0.11.10 to fix tokio thread panic
-rw-r--r--Cargo.toml2
-rw-r--r--src/modules/stocks.rs15
2 files changed, 10 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 6edfccd..34bc156 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -28,7 +28,7 @@ windmark = { version = "0.2.0", features = [
"logger",
"auto-deduce-mime"
] } # Gemini Server Framework
-reqwest = { version = "0.11.10", features = ["blocking", "json"] } # HTTP Client
+reqwest = { version = "0.10.10", features = ["blocking", "json"] } # HTTP Client
serde_json = "1.0.79" # JSON Serialization
log = "0.4.16" # Logging Macros
pretty_env_logger = "0.4.0" # Pretty Log Printing
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);