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
Not able to await on write!
in spawned async task
#516
Comments
Acknowledged, that's a serious problem of the std family of macros, they are not Send. |
@skade any thoughts on using locks to help with this or do you think the ergonomics hit is not worth the performance penalty? |
We had some discussions around what the best solution is. We prefer a solution of some kind that works, but are not exactly sure which one. |
The two options seem to be: either we introduce spawn_local, or std make Arguments Send. The latter seems really hard but yields the best ergonomics, but the former we could do ourselves (likely at the cost of some ergonomics). |
It seems |
Related issue from the compiler: rust-lang/rust#64856 |
It seems like This works fine:
But
|
I'm sorry to delete the old code. For async-std-1.9.0, macro macro_rules! println {
($($arg:tt)*) => (async {
let mut stdout = async_std::io::stdout(); // make stdout live longer than .await
if let Err(e) = {
let x = writeln!(stdout, $($arg)*);
// drop Arguments<'_> and [ArgumentV1<'a>] to make them live shorter than .await
x
}.await {
panic!("failed printing to stdout: {}", e);
}
});
} It depends on that |
This is very easy to reproduce:
This leads to the following error:
This seems to be caused by
core::fmt::Void
not beingSend
. I would expect this to be able to work.The text was updated successfully, but these errors were encountered: