Afzal Najam
02/04/2021, 5:03 PMval parentScope = CoroutineScope(Dispatchers.Default + Job() + exceptionHandler)
But if I create it like this, and one of its children jobs had an exception, siblings didn't fail and other coroutines were able to launch just fine:
val parentScope = MyScope()
Where MyScope
is:
class MyScope: CoroutineScope {
override val coroutineContext: CoroutineContext
get() = Dispatchers.Default + Job() + exceptionHandler
}
I thought that both `parentScope`s would behave exactly the same. Am I missing something?
Here's a gist: https://gist.github.com/AfzalivE/3bfe168e879ba8b97ad62292217b0491louiscad
02/04/2021, 5:18 PMIvan Pavlov
02/04/2021, 8:25 PMAfzal Najam
02/04/2021, 8:27 PMIvan Pavlov
02/04/2021, 8:38 PMAfzal Najam
02/04/2021, 8:39 PMlouiscad
02/04/2021, 8:40 PMAfzal Najam
02/04/2021, 8:40 PMlouiscad
02/04/2021, 8:42 PMCancellationException
) reaching a coroutine launcher will cancel the Job
in its scope, and there's no going back from a cancelled Job
instance.Afzal Najam
02/04/2021, 8:45 PMparentScope
created using the CoroutineScope function does get cancelled when a job in its scope throw an exception. Am I missing something?louiscad
02/04/2021, 8:46 PMIvan Pavlov
02/04/2021, 8:48 PMget
?louiscad
02/04/2021, 8:48 PMCancellationException
). I think that route would work fine for you as well.Afzal Najam
02/04/2021, 9:00 PMlouiscad
02/04/2021, 9:06 PM