Robert Jaros
11/01/2019, 1:24 PMlaunch to GlobalScope.launch the exception is printed twice:
https://pl.kotl.in/13sfoRVtk
Shouldn't the unhandled exception cancel the job in both cases?streetsofboston
11/01/2019, 1:39 PMstreetsofboston
11/01/2019, 1:40 PMtest.run() is never called -> One exception printedstreetsofboston
11/01/2019, 1:42 PMGlobalScope to ‘handle’ the exception. It just prints it out and, since it has no Job, it never gets canceled, it never finishes. This means that the outer-most CoroutineScope (the one provided by runBlockingTest) never gets canceled; the exception didn’t happen in that scope, it happened in the GlobalScope. This means that the code keeps running and test.run() is called againRobert Jaros
11/01/2019, 1:48 PMtest.run() IS called.
https://pl.kotl.in/CuGYbUKsZ
But it never runs its launch() block.Robert Jaros
11/01/2019, 1:54 PMby CoroutineScope(Dispatchers.Default). Can it be "fixed" somehow for later use? Or it's just dead? 🙂Robert Jaros
11/01/2019, 1:57 PMstreetsofboston
11/01/2019, 1:57 PMrun of Teststreetsofboston
11/01/2019, 1:59 PMtest.run() (exception happened), the 2nd call to launch will be canceled immediatelystreetsofboston
11/01/2019, 2:06 PMstreetsofboston
11/01/2019, 2:07 PMRobert Jaros
11/01/2019, 2:13 PMRobert Jaros
11/01/2019, 2:13 PMbdawg.io
11/01/2019, 7:24 PMSupervisorJob if you don't want it to cancel val job = SupervisorJob()
val scope = CoroutineScope(Dispatchers.Main + job)
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-supervisor-job.html