Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion test/async/container/policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,26 @@ def child_exit(container, child, status, name:, key:, **options)
end.new

container = Async::Container.best_container_class.new(policy: stop_policy)
trigger = IO.pipe

3.times do |i|
container.spawn(name: "worker-#{i}") do |instance|
instance.ready!
exit(1)

# Only the first worker exits, and only once all workers are ready, so exactly one `child_exit` drives the stop. Otherwise multiple simultaneous exits can race the `stopping?` check and inflate `stop_count`.
if i.zero?
trigger.first.gets
exit(1)
else
sleep
end
end
end

container.wait_until_ready

trigger.last.puts("exit")

container.wait

expect(stop_policy.stop_count).to be == 1
Expand Down
Loading