defmodule PoolTest do
use ExUnit.Case, async: true
test "naive pool" do
child = {NimblePool, worker: {PortPool, :cat}, name: PortPool}
Supervisor.start_link([child], strategy: :one_for_one)
for i <- 0..10000 do
PortPool.command(PortPool, "hello#{i}\n")
end
end
test "naive pool 2" do
child = {NimblePool, worker: {PortPool, :cat}, name: PortPool2}
Supervisor.start_link([child], strategy: :one_for_one)
for i <- 0..10000 do
PortPool.command(PortPool2, "hello#{i}\n")
end
end
end
It is not related to multiple entries, just a race with the parent process linked. If you use a sleep in the second test it could still reproduce it :)
the tests passes but it raises error below if there are two instances of the port pool.