https://kotlinlang.org logo
#coroutines
Title
# coroutines
d

Dan T

12/19/2017, 6:03 PM
i'm stuck on an issue where i'm going from an akka stream via function to a suspended function, but the suspended function isn't returning. I presume I'm doing something wrong, but don't know how to narrow the issue further. any tips? p.s. are there tracing facilities for coroutines?
Copy code
private fun processMessage(record: KafkaMessage) {
    runBlocking {
        launch {
            handler.doSomething(record.data) // its implementation simply returns
            log.debug("2") // NOT CALLED
        }.join()
    }
}
d

dave08

12/19/2017, 6:25 PM
Maybe an uncaught exception? Launch has a tendancy of hiding them... try
async { }.await()
, itll throw if there is an exception...
d

Dan T

12/19/2017, 6:33 PM
tried that too..i tried making the function return a boolean and used async/await, but same result. thanks though
e

elizarov

12/19/2017, 6:43 PM
It is hard to troubleshoot. Can you do a shorter example? Anyway, neither launch/join, nor async/await are needed. Just do
Copy code
runBlocking { handler.doSomething(...) }
d

Dan T

12/19/2017, 7:18 PM
thanks for the improvement - still the same problem. if i remove the coroutine usage it works, so i'm guessing it's an akka <-> coroutines issue. i'll create a small sample app.
4 Views