I have a strange issue, but I am not sure if it is...
# coroutines
a
I have a strange issue, but I am not sure if it is related to coroutines. But I have the following unit test:
Copy code
@Test fun testActor() {
  val testActor = actor<String> {
    println(channel.receive())
  }

  testActor.sendBlocking("CHANNEL-MESSAGE")
}
When I run this locally on my machine I see
CHANNEL-MESSAGE
being printed. But when I build this with docker it is never received. My
Dockerfile
looks like:
Copy code
FROM maven:3.3.9-jdk-8
COPY . project/
WORKDIR project
RUN mvn clean package
I used version
3.3.9
which is the same on my local machine. With docker it actually freezes on the
sendBlocking
. Anyone a clue how this is possible?
g
You use blocking operation. Maybe you blocked all the threads for some reason? Is it reproducible with such simple example?
Maybe you could provide some self contained example
a
Making a self contained example is difficult with this one. Because of docker and the configuration. The thing what "helped" was increasing the amount of cores in the container from 2 (default) to 3 (on Windows).
g
I think you blocked all the threads of common pool and no more threads to dispatch coroutines
a
But then it is still unclear to me why it is happening in docker only. when I do this on my host exactly the same way it works
g
Because on your host you just have more available threads in CommonPool. CommonPool is
cpuNum - 1
But, I do not exclude that there is still some bug, this is why I asked self contained example
No need to set amount of cores for docker, you can instead set system property
kotlinx.coroutines.default.parallelism
to set minimal amount of threads in commonpool
👍 1
also you can try to use new experimantal dispatchers, that can handle such cases automatically and start additional threads if all of existing are blocked
actually with 2 cores you have only 1 thread in CommonPool