spierce7
05/22/2022, 6:35 PMcoroutineScope {}
, calling several async methods, and collecting the deferreds into a MutableList<Deferred<Any>>
. Before the coroutine is over, I call deferreds.awaitAll()
on the list. This isn’t actually necessary if I don’t care about the results, right? A parent suspend function won’t complete until all it’s children coroutines have completed, right?andylamax
05/22/2022, 6:49 PMspierce7
05/22/2022, 7:21 PMspierce7
05/22/2022, 7:21 PMStylianos Gakis
05/22/2022, 10:02 PMspierce7
05/22/2022, 10:03 PMspierce7
05/22/2022, 10:03 PMspierce7
05/22/2022, 10:04 PMjulian
05/22/2022, 11:02 PMI’m pretty sure the parent coroutine will succeed, even if the child coroutine fails.Depends what sort of
Job
is in the parent coroutine's context.julian
05/22/2022, 11:09 PMlaunch would ignore the errorsIt doesn't. But unlike
coroutineScope
, exceptions can't be caught by wrapping in try-catch
. And depending on the Job
in the launch
-ed coroutine parent's context, failure may not propagate up the job hierarchy.spierce7
05/22/2022, 11:28 PMDepends what sort ofWhat are the different types ofis in the parent coroutine’s context.Job
Job
for this?julian
05/23/2022, 12:11 AMSupervisorJob
will not fail or propagate failure up the job hierarchy when its children fail. Whereas, a regular Job
will.spierce7
05/23/2022, 12:12 AMjulian
05/23/2022, 12:14 AMgildor
05/23/2022, 8:51 AMSo I don’t care about the actual results, but I do care if an exception is thrownBecause coroutineScope will rethrow exception, you are fine. If you want to catch it, just wrap coroutineScope with try/catch as any other suspend function And you almost never want supervisorScope on practice
Stylianos Gakis
05/23/2022, 8:54 AM