Skip to content

Instantly share code, notes, and snippets.

@ioquatix
Created February 21, 2025 10:24
Show Gist options
  • Save ioquatix/a9c04db2ead00a6491df1b9c18295962 to your computer and use it in GitHub Desktop.
Save ioquatix/a9c04db2ead00a6491df1b9c18295962 to your computer and use it in GitHub Desktop.
Dump task hierarchy from another thread
#!/usr/bin/env ruby
require "async"
request = ::Thread::Queue.new
thread = Thread.new do
while true
sleep 10
IO.pipe do |r, w|
request.push(w)
puts r.read
end
end
end
Async do |task|
task.async do
while w = request.pop
task.print_hierarchy(w)
w.close
end
end
task.annotate("Main Task")
while true
sleep 1
puts "Main Task"
end
end
thread.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment