-
Notifications
You must be signed in to change notification settings - Fork 4.5k
RpcClient no longer panics in a tokio multi-threaded runtime #16385
Conversation
let request_id = 1; | ||
|
||
let request_json = request.build_request_json(request_id, params); | ||
let request_id = self.request_id.fetch_add(1, Ordering::Relaxed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freebie!
|
||
#[tokio::test(flavor = "current_thread")] | ||
#[should_panic(expected = "can call blocking only when running on the multi-threaded runtime")] | ||
async fn http_sender_ontokio_current_thread_should_panic() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't great, but I don't see a way around. Fortunately [tokio::main]
creates a multi_thread
runtime, so most users won't see this (but #[tokio::test]
, sans flavour, is current_thread
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, obv not ideal but okay for now. I haven't thought of anything better.
|
||
#[tokio::test(flavor = "current_thread")] | ||
#[should_panic(expected = "can call blocking only when running on the multi-threaded runtime")] | ||
async fn http_sender_ontokio_current_thread_should_panic() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, obv not ideal but okay for now. I haven't thought of anything better.
Codecov Report
@@ Coverage Diff @@
## master #16385 +/- ##
=======================================
Coverage 80.1% 80.1%
=======================================
Files 411 411
Lines 110155 110194 +39
=======================================
+ Hits 88268 88366 +98
+ Misses 21887 21828 -59 |
Post-tokio 1 upgrade (Solana 1.6.2),
RpcClient
would panic if run from within a tokio runtime. Fix it by shuttling the blocking requests off to a different tokio threadOne glorious day we'll have an async RpcClient (blocked on the jsonrpc crates turning into jsonrpsee crates for a tokio 1 update here), after which we can autogen the RpcClient bindings. For now
RpcClient
working in async is better than nothing though.