-
Notifications
You must be signed in to change notification settings - Fork 155
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
It's not clear how to use Executor instead of smol::spawn #223
Comments
You just forgot to run the executor on the future with timeouts. This should work: ...
let ex = Executor::new();
smol::block_on(ex.run(async {
ex.spawn(wait_for_timeout(4, "four")).detach();
ex.spawn(wait_for_timeout(3, "three")).detach();
ex.spawn(wait_for_timeout(2, "two")).detach();
ex.spawn(wait_for_timeout(1, "one")).detach();
wait_for_signal(&ctrl_c).await;
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a demo of using
spawn()
to run some timeouts:It should print:
And exit (early, even) if you press Ctrl+C.
The docs for
smol::spawn()
say:So I tried replacing
smol::spawn
with my own executor:Now nothing is printed. Ctrl+C still works. I assume there is something else I have to do to get the executor working, but it's not documented what. The docs for Executor use something called
easy_parallel
which isn't part of smol.System: rustc 1.49, Ubuntu 20.10, smol 1.2.5.
The text was updated successfully, but these errors were encountered: