Futures-rs: thread 'main' panicked at 'cannot execute `LocalPool` executor from within another executor: EnterError'

Created on 6 Apr 2021  路  5Comments  路  Source: rust-lang/futures-rs

when I use block_on ,I get this panic and after investigate I found that is because of recursive block_on , so is there is an workaround for that ?
Thank you for advance.

A-executor C-question

All 5 comments

Can you .await the second future instead of calling block_on again?

@seanmonstar if I have an option to await so why I will use block_on ?
I have to use block_on so is there is a way to use block_on ?

Not easily at all.

The panic is there to catch you from a very likely deadlock. That's because if the second block_on isn't ready immediately, it block (put the thread to sleep) until it's ready, but since the thread is asleep, the local pool will never be able to poll again and wake it up.

thank you for help.
regarding to poll next and wake up, executors and how rust handles await internally how can I understand those all ,could you recommend tutorial?

This page in the Tokio tutorial goes into details about Future, wakers, executors, etc. If you're newer to async Rust in general, it may help to start reading that tutorial from the beginning, so you have more context, instead of diving into the deep end immediately.

Was this page helpful?
0 / 5 - 0 ratings