I'm having the following code. My jvm is not termi...
# coroutines
t
I'm having the following code. My jvm is not terminating after executing the last statement in the
runBlocking
lambda? Is any of my coroutine is leaking? https://gist.github.com/thiyagu06/9813da5a5b12ad91ce0ad8b26043d867#file-hangingcoroutines-kt-L79
c
I thought stop() will only mark the job cancelled and will emit a CancellationException once its done. Maybe this helps: https://kotlinlang.org/docs/reference/coroutines/cancellation-and-timeouts.html#making-computation-code-cancellable
t
once I called
stop()
, coroutines are stopped producing/consuming values.. I mean both
println
statments stop appearing in the console. but somehow
main()
is not exiting.
c
My mistake, didn’t see isActive check.
d
I have a theory. Try shutting down the dispatcher after you're done. i.e call
dispatcher.close()
.
👍 2
t
Yes... It worked after the
close()
method. But if I use
<http://Dispatchers.IO|Dispatchers.IO>
jvm exists automatically. Any reason for this behavior?
d
Not entirely sure. Probably something to do with daemons.
t
cool 👍 Thanks