3 ms·
They're referring to not using .Wait()/.Result on awaitable functions, not about making every function async regardless of whether it needs it. This was a commo
by Salgat 2y ago
They're referring to not using .Wait()/.Result on awaitable functions, not about making every function async regardless of whether it needs it. This was a common pitfall that people would do back in the day to avoid having to refactor everything when adding async support to the code, since one await deep in the code could cause half your functions to need async added in a refractor.
- mrkeen 2y ago> not about making every function async regardless of whether it needs it. That's what you and I wrote. That's not what the article wrote. "efforts to be async amount to nothing unless the entire call stack is async" The entire call stack? "it is best to go all in, and make everything async at once." Go all in? This beyond 'a little bit unclear' into 'incorrect' territory, especially since the preceding paragraph said "there's been lots of confusion on the best practices for async and how to use it properly." Is there a single NB or asterisk-like comment on the whole page that walks back the "all in" comment to something like "calling sync from async is fine." ?
- Salgat 2y agoHe explains the same thing I did right in his example. Don't use .Result to force sync over async.
- mrkeen 2y agoHe says not to blocking-wait for async methods, which is correct. He makes no direct comment, afaik, on calling sync methods from async methods. The reader is left only with efforts to be async amount to nothing unless the entire call stack is async and it is best to go all in, and make everything async at once. and must somehow parse this as some of the call stack, and make some things async.
- davidfowl 2y agoIf I made mistakes feel free to file an issue or even send me a PR. It's open source! That said, you're right that I don't say how best to call sync from async methods (the latter is more difficult as there's no good way do it well).