David Glasser
03/26/2020, 5:51 PMwithTimeout(5000L) {
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
somePotentiallySlowThreadBlockingFunction()
}
}
Note that I'm perfectly fine with the fact that the timeout won't actually stop the work from happening in somePotentiallySlowThreadBlockingFunction
. This is happening at global process shutdown so the important thing is being able to move on to the next step of shutdown in finite time, not absolutely making sure that somePotentiallySlowThreadBlockingFunction
doesn't continue.
Like, I know withTimeout
alone won't work with non-cooperative code, but does the withContext maybe make it work?withTimeout(timeout) { d.await() }