Skip to content

Commit

Permalink
Don't use Timeout and don't catch ECHILD
Browse files Browse the repository at this point in the history
Timeout is flaky

We have a pid - one of the waitpid2s in subprocess must succeed,
so we should never get ECHILD
  • Loading branch information
raylu-stripe committed Jul 13, 2016
1 parent 93acc6d commit 9a281b8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/integration/_lib/helpers/einhorn_helpers.rb
Expand Up @@ -40,28 +40,28 @@ def with_running_einhorn(cmdline, options = {})
begin
stdout, stderr = process.communicate
rescue Errno::ECHILD
# It's dead, and we're not getting anything. This is
# peaceful.
# It's dead, and we're not getting anything. This is peaceful.
end
end
yield(process) if block_given?
rescue Exception => e
rescue
unless (status = process.poll) && status.exited?
process.terminate
end
raise
ensure
unless (status = process.poll) && status.exited?
begin
Timeout.timeout(10) do # (Argh, I'm so sorry)
status = process.wait
for i in 1..10 do
status = process.poll
if status && status.exited?
break
end
rescue Timeout::Error
sleep(1)
end
unless status && status.exited?
$stderr.puts "Could not get Einhorn to quit within 10 seconds, killing it forcefully..."
process.send_signal("KILL")
status = process.wait
rescue Errno::ECHILD
# Process is dead!
end
end
communicator.join
Expand Down

0 comments on commit 9a281b8

Please sign in to comment.