Created
February 21, 2025 10:24
-
-
Save ioquatix/a9c04db2ead00a6491df1b9c18295962 to your computer and use it in GitHub Desktop.
Dump task hierarchy from another thread
This file contains hidden or 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
#!/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