Skip to content
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

thread 'main' panicked at 'cannot execute LocalPool executor from within another executor: EnterError' #2386

Closed
abdelmonem17 opened this issue Apr 6, 2021 · 5 comments
Labels
A-executor Area: futures::executor C-question

Comments

@abdelmonem17
Copy link

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.

@seanmonstar
Copy link
Contributor

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

@abdelmonem17
Copy link
Author

@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 ?

@seanmonstar
Copy link
Contributor

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.

@abdelmonem17
Copy link
Author

abdelmonem17 commented Apr 6, 2021

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?

@seanmonstar
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-executor Area: futures::executor C-question
Projects
None yet
Development

No branches or pull requests

3 participants