-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
You didn’t fix some “race condition” or whatever. I never wanted to and "async" doesn't mean "par", i.e. parallel:
You totally misundertood my post. I was only talking about different But this is fine that it is sequential, I do not bother whether it is sequential ordering problem. |
For your problem of a "race condition", if you want to load in parallel, I guess See also here:
https://learn.adafruit.com/adafruit-esp32-s2-feather/multitasking-with-asyncio |
The multiple Promise chain fetches did indeed run in “parallel”. At least call their then() part, in first come first serve order. On the other hand Whether there is some “race condition” in the parallel case I don’t “race condition” with the rest, like in true parallel, which might or might not be true, this depends on a the completion of the fetches, you could use: How to do multiple fetch requests in parallel using JavaScript? The above suggests Promise.all() from JavaScript. But mostlikely |
Apologies for the lazy PR message - I was doing this in a bit of a rush. Indeed the undeterministic order of the On the parallel fetch; with anything like that you can always just run the fetches and resolve them later like below, no need for promise.all. The only reason I didn't do this in the PR is because the site loads in a negligible amount of time so there was no point in making those kinds of changes to keep the fetch calls in 'parallel'. // Start fetches in 'parallel'
const unresolvedFetch1 = fetch(`http://example.org#1`)
const unresolvedFetch2 = fetch(`http://example.org#2`)
doTaskWithResponse(await unresolvedFetch1);
doTaskWithResponse(await unresolvedFetch2); Sorry for any confusion with my lazy use of terminology around changes in syntax/syntaxtic sugar vs. changes in behavior. |
Ok, I only wanted to make sure that nothing got broken by some rush. |
Uses async/await to avoid race conditions. Making the fetches in-order doesn't noticably slow down anything so no point trying to make just those parts async for now.