Skip to content

Instantly share code, notes, and snippets.

@therrick
Created December 19, 2015 12:15
Show Gist options
  • Save therrick/4f8c4dc34411bf0bbdf2 to your computer and use it in GitHub Desktop.
Save therrick/4f8c4dc34411bf0bbdf2 to your computer and use it in GitHub Desktop.
stacktrace for rspec hangs
# from https://github.com/rspec/rspec-rails/issues/1353
# put this in spec/initializers/debug_hangs.rb, then use 'kill -USR1 <rspec-pid>' when rspec hangs
puts "rspec pid: #{Process.pid}"
trap 'USR1' do
threads = Thread.list
puts
puts '=' * 80
puts "Received USR1 signal; printing all #{threads.count} thread backtraces."
threads.each do |thr|
description = thr == Thread.main ? 'Main thread' : thr.inspect
puts
puts "#{description} backtrace: "
puts thr.backtrace.join("\n")
end
puts '=' * 80
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment