very very dumb question. I have a `csvReader.open(...
# announcements
p
very very dumb question. I have a
csvReader.open(file) { ... }
function from a library. The problem is the lambda is not suspend-aware. Is there any way to call a suspend fn in the lambda there other than calling runBlocking? FWIW, this is all inside a suspending function, so I do not want to do
runBlocking
inside a
suspend
function. It just feels so wrong.
n
so to be clear, your the containing function has
suspend
, the
open
function callback is not
suspend
, and you want to be able to call other
suspend
methods from inside the callback?
p
Yes.
a
Why do you want to suspend while reading a file from a blocking reader API?
p
I was using the library wrong, I just realized I can readAsSequence inside the open lambda, get the sequence out, and process it as I want in the suspending context out of the blocking callback to open. Thanks @Adam Powell!
Actually that won't work because the stream is closed outside the lambda, and reading from sequence fails. Oh well. I found we have the author and a (small) community hanging around in #kotlin-csv, moving this there
­čĹŹ 1