Prateek Kumar
06/26/2023, 10:26 PMfun getPreferenceLong(key: String, defaultValue: Long): Long {
return runBlocking {
context.dataStore.data.map {
it[longPreferencesKey(key)] ?: defaultValue
}.first()
}
}
This mostly throws the exception when called from a RxJava Code , for now can’t make it return Flow as it has usages in legacy codebase as wellSam
06/27/2023, 7:45 AMInterruptedException
isn’t directly related to coroutines: it’s linked to the fact that you’re blocking a thread. If runBlocking
throws InterruptedException
, it means something interrupted the calling thread while it was blocked. This typically means that the application is attempting to stop the thread and discard its work. The proper way to handle it is generally to allow the exception to propagate so that the thread does indeed terminate.Sam
06/27/2023, 7:48 AMPrateek Kumar
06/27/2023, 8:50 AM