Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
they will all wait for each other to resolve or reject then it cascades down........, I dont know the word for it
-
killames5733yBut like inside one of the asyncs I’m not awaiting a call to another async and adding an await seemed to allow the code to progress after a long pause for some unknown reason
I know how I supposed to work but it’s not doing that -
if you mean
const f = async () => {
asyncFunc();
}
await f();
Then asyncFunc() will get executed but it won't be awaited/blocking (you could add a .then() to it too get the return value) -
killames5733y@pythonPlusPlus yes that is about right but add another layer and if don’t await the innermost function it freezes sometimes
-
@killames Maybe a simple example would help me understand. I am wondering how it can freeze
-
killames5733yAsync eventhandler()
{
Await asyncfunction()
{
Asyncfunctionthatdoesnetworkcall()
}
}
//pseudocode
@pythonPlusPlus -
@killames The inner most call without await should not be blocking. No await, no blocking. The only way for it to freeze is to have a computationally intense task right away (while (true) {}), that will block.
-
killames5733y@pythonPlusPlus what I’m saying is there are times the async code never returns it fires one part and freezes
It’s not standard behavior -
Crost41083y@killames have you considered you might have a long running micro task that is holding up execution of future macro tasks and therefore freezing the app?
If you look at a list of what code causes micro Vs macro and compare your script you might see something. Blocked event loop. -
killames5733y@Crost I fixed this by taking the code that does the network op and defining the then and catch calls
And then adding a timer to manage these and in the then code adding then back to the main queue already being handled
And now it works blazing fast
Literally the only difference is one last await level per item
I think await adds some significant overhead that it shouldn’t -
killames5733y@Crost that’s my gut feeling anyway
The more levels of async you add with awaits in them the more likely something will bungle that shouldn’t
Doesn’t the os usually provide the threading mechanism ? -
Crost41083y@killames it's all single threaded. The engine achieves async using what amounts to a fancy loop.
-
killames5733y@Crost I know I know but it seems that the one op was freezing because of the extra nesting
So if you’re awaiting a promise and the async function returning the promise calls another async function and doesn’t await it could this counterintuitively cause the whole thing to freeZe ?
question