Skip to content

Instantly share code, notes, and snippets.

@YanhaoYang
Created October 19, 2018 18:41
Show Gist options
  • Save YanhaoYang/8ddbf16ea47839e53665a28bda814fc2 to your computer and use it in GitHub Desktop.
Save YanhaoYang/8ddbf16ea47839e53665a28bda814fc2 to your computer and use it in GitHub Desktop.
Print the call stacks in a multithread application, say puma, to know which threads are blocked
before_fork do
trap 'TTIN' do
Thread.list.each do |thread|
puts "\nThread TID-#{thread.object_id.to_s(36)}"
puts thread.backtrace.join("\n")
puts "\n"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment