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 PMtest.run()
is never called -> One exception printedGlobalScope
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.by CoroutineScope(Dispatchers.Default)
. Can it be "fixed" somehow for later use? Or it's just dead? 🙂streetsofboston
11/01/2019, 1:57 PMrun
of Test
test.run()
(exception happened), the 2nd call to launch
will be canceled immediatelyRobert 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