>java.lang.IllegalStateException: Already resum...
# coroutines
p
java.lang.IllegalStateException: Already resumed
So, `CoroutineContext`s are not reusable
p
I don’t deny it’s a solution, but it’s clearly one that’s not prod-ready. Sad 😞
e
Can you please elaborate what it has to do with contexts? Do you have an example code?
p
yes! what I’m trying to write is some code that enforces every flatMap to happen on the CC that’s been passed, so it reuses it
the problem is that the CC isn’t reusable so I cannot start a new coroutine for every step, even if I use EmptyCoroutineContext
e
I don’t get it.
CoroutineContext
is an immutable state-less data structure. Your problem is with something else. What kind of error you are getting?
p
java.lang.IllegalStateException: Already resumed
If I give a new CoroutineContext every time it works just correctly
the same CC is being used for multiple active corutines
so it may be the stacklabels we’re copying?
e
This is exception can be only thrown by either
suspendCoroutine
or
suspendCancellableCoroutine
and has nothing to do with the context. It happens when you try to resume the same
Continuation
twice
context, by itself, has no state
p
hmmmm
that’s good info
I can come back to the code with that, thanks 😄