3 ms·
> In other languages like python you don't have to. I'm confused since "I don't have to do this in python" is probably the worst choice you could make to try a
by terminalbraid 2y ago
> In other languages like python you don't have to.
I'm confused since "I don't have to do this in python" is probably the worst choice you could make to try and run away from this. Python does have async/await and the semantics are very similar (in fact they're more restrictive in some ways). You will get the same interpreter errors if you try to call async functions and awaits in a non-async function.
https://docs.python.org/3/library/asyncio.html https://docs.python.org/3/library/asyncio.html
You're more likely upset that Promises in javascript are more common, but if you understood what the js interpreter is doing in an async event loop and the backing structures needed to make those calls you'd understand the need for the correct annotations.
If your gripe is with just needing await/async in general, you should know you don't actually ever need to use await/async. The .then chaining form is an alternate and equivalent way of handling promises.
Since, if you've read this far, you're probably saying to yourself "this is guy is dumb and doesn't really understand what I'm talking about". I'll give you a rope I'll claim you don't want and which solves the problem you think you have.
You'll be happy to learn you are not correct to say you need to use async await or .then. You can break out of the async nesting and just wrap whatever async call you can't get away from in a synchronous wrapper.
The answers (with much stronger warnings than I've given you) await you here
https://stackoverflow.com/questions/9121902/call-an-asynchronous-javascript-function-synchronously https://stackoverflow.com/questions/9121902/call-an-asynchro...