Created
May 18, 2020 11:10
-
-
Save atd/654fa37393fde5a739e95a2b5e935380 to your computer and use it in GitHub Desktop.
rspec backtrace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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