Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atd/654fa37393fde5a739e95a2b5e935380 to your computer and use it in GitHub Desktop.
Save atd/654fa37393fde5a739e95a2b5e935380 to your computer and use it in GitHub Desktop.
rspec backtrace
# Source: https://github.com/rspec/rspec-rails/issues/1353#issuecomment-93173691
# Add to spec/spec_helper.rb
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
# Then $ kill -USR1 <the pid>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment