-
Notifications
You must be signed in to change notification settings - Fork 74
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
crypto_msg_parser::parse_trade() : Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context. #58
Comments
Can you remove line numbers from your code snipet above? I'd like to run you code on my machine |
Here you go use crypto_crawler::{crawl_trade, MarketType};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
let (tx, rx) = std::sync::mpsc::channel();
tokio::task::spawn(async move {
crawl_trade(
"kucoin",
MarketType::LinearSwap,
Some(&["SOLUSDTM".to_string()]),
/*
MarketType::Spot,
Some(&["SOL-USDT".to_string()]),
*/
tx,
)
.await
});
for msg in rx {
//https://github.com/crypto-crawler/crypto-crawler-rs/blob/main/crypto-crawler/src/msg.rs
let trades =
crypto_msg_parser::parse_trade(&msg.exchange, msg.market_type, &msg.json).unwrap();
let trade = &trades[0];
println!("{:#?}", trade);
}
} and [package]
name = "qk"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
crypto-crawler = { git = "https://github.com/crypto-crawler/crypto-crawler-rs", branch = "main" }
crypto-msg-parser = { git = "https://github.com/crypto-crawler/crypto-msg-parser", branch = "main" }
crypto-message = { git = "https://github.com/crypto-crawler/crypto-msg-parser", branch = "main"}
tokio = { version = "1", features = ["macros", "rt-multi-thread"] } |
I have the same issue.any resolutions? @panicfarm |
Looking into this issue, will update |
@soulmachine I believe the issue is here: The function is blocking because inside it contains blocking reqwest: https://github.com/crypto-crawler/crypto-msg-parser/blob/3ba78a12e34e9b93468e6dc26d68ad3dec620a97/crypto-contract-value/src/exchanges/utils.rs#L7 You could make the entire |
I think whether |
any update? @soulmachine |
Not yet, still working on it |
I am using the following code (collected from your examples):
Only for MarketType::LinearSwap (but not for MarketType::Spot because https://github.com/crypto-crawler/crypto-msg-parser/blob/3ba78a12e34e9b93468e6dc26d68ad3dec620a97/crypto-contract-value/src/exchanges/kucoin.rs#L198 never gets called for Spot) I get the following panic with the debug build (this never happens with a release build, i think it's something debug-specific? with blocking
http_get("https://api-futures.kucoin.com/api/v1/contracts/active")
reqwest in crypto-contract-value-1.7.7/src/exchanges/kucoin.rs:181 ).PS. With the release build, i let it run for several days, but the websocket stopped getting new messages after 2 days. I rebuilt as a debug and ran into the panic above. Should I file a separate Issue on the stuck websocket (unsure how to debug that, strace showed waiting for some FUTEX)?
The text was updated successfully, but these errors were encountered: