-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kotlin Multi<T>.asFlow() blocking the thread #1103
Comments
Thanks for reporting, need to have a detailed look (again ;)). |
emmmm,I'm a bit green, can't understand you completely. Do you mean |
I'm not saying runBlocking should be used, but only that I thought it behaves that way, at least according to the current unit tests. You can definite confirm, that your example without |
yes. When I change suspend fun getByProj(projectId: Int): List<InputDataLoadResult> =
pgPool.preparedQuery("select * from input_data where project_id=$1")
.execute(Tuple.of(projectId))
.onItem().transformToMulti { Multi.createFrom().iterable(it) }
.filter { it != null }
.map { InputDataLoadResult(it) }
.collect()
.asList()
.awaitSuspending()
// .asFlow()
// .toList()
The following code shows this problem well.The function @Path("/")
class TestResource {
@GET
@Path("/test")
@ExperimentalCoroutinesApi
suspend fun test() = getTestStrings()
}
@ExperimentalCoroutinesApi
suspend fun getTestStrings() : List<String> {
val l = ArrayList<String>()
for (i in 1..100) {
l.add("this is item $i")
}
val collect = Multi.createFrom().iterable(l)
.asFlow()
.toList()
println("get all items")
return collect
}
fun main() = runBlocking {
getTestStrings()
println("returns success")
return@runBlocking
} the log :
|
Ok, I could properly reproduce it using your example - thank you. |
#1103 Refactor Multi.toFlow() to avoid blocking - Mutiny2
#1103 Refactor Multi.toFlow() to avoid blocking - Mutiny1
Hey @j128919965, Mutiny 1.8 just go released, containing this issue's solution. Best regards - and keep reporting ;) |
Description
Hi. I'm using quarkus with mutiny and kotlin. I found that when the number of elements in the
Multi
reaches a large number,Multi<T>.asFlow()
will blocking the thread,and never recovery.The log :
My code:
I noticed that
io.smallrye.mutiny.coroutines Multi.kt:53
usesrunblocking
to send items to the channel. I tried to change it tolaunch
, the code is no longer blocking.I dont know is this a bug? Or some other reason to use
runblocking
rather than usinglaunch
?Env
windows11
graalvm ce 17
kotlin 1.7.20
quarkus 2.13.3.Final
The text was updated successfully, but these errors were encountered: