Jonathan
09/12/2018, 2:06 PMawaitAll(one, two) by one.await(); two.await() in this code?marstran
09/12/2018, 2:06 PMJonathan
09/12/2018, 2:07 PMJonathan
09/12/2018, 2:07 PMJonathan
09/12/2018, 2:07 PMJonathan
09/12/2018, 2:07 PMJonathan
09/12/2018, 2:08 PMone.await hangsVsevolod Tolstopyatov [JB]
09/12/2018, 2:10 PMfoo, one and two. async does not cancel its parent.
foo is waiting for one (which sleeps forever), while two already failed, but this exception is not delivered, because no one called await on it.
Complexity behind awaitAll implementation is exactly to resolve this problemJonathan
09/12/2018, 2:13 PMJonathan
09/12/2018, 2:14 PMasync cancel the parent on failure)Vsevolod Tolstopyatov [JB]
09/12/2018, 2:16 PMasync fails, but then in
try {
async { throw MyException() }.await()
} catch (e: MyException) {
}
catch block won’t be executed because cancellation throws CancellationException 🙂Vsevolod Tolstopyatov [JB]
09/12/2018, 2:17 PMGlobalScope.async catch block will be executed and that’s where this mental model breaks 😞codyoss
09/12/2018, 2:20 PMVsevolod Tolstopyatov [JB]
09/12/2018, 2:23 PMVsevolod Tolstopyatov [JB]
09/12/2018, 2:32 PMcodyoss
09/12/2018, 3:03 PM