Hello @armando! welcome to in_thread 
As you have seen, there are little to no documents anywhere about accessing Sonic Pi internals. I myself would love to see some support for things like using introspection - but whether it will ever happen depends mostly on whether there is a 10-year-old-child friendly way to do it, and then on having the resources to add the features in!
Here is an example showing a way you can find out the currently running live_loops:
define :live_loop_names do
@named_subthreads.map do |name, thread|
name.to_s[10..-1] if name.to_s.start_with?('live_loop')
end.compact
end
live_loop :test do
sleep 1
end
Run it, and change the name of the loop to say :test2
, then run:
puts live_loop_names
You should see the following result:
["test2", "test"]
However, there is one more thing to note:
If you have something roughly similar to the following:
live_loop :test do
stop
end
puts live_loop_names
… and run it, you will see:
["test"]
As the loop has not yet been terminated by the time we look up the names. In order to make sure it has been stopped by the time we look up thread names, we’d need to either delay the call to live_loop_names
, or maybe have a use_real_time
or with_real_time
in there:
define :live_loop_names do
@named_subthreads.map do |name, thread|
name.to_s[10..-1] if name.to_s.start_with?('live_loop')
end.compact
end
with_real_time do # or just have use_real_time above the loop somewhere instead of using the block version
live_loop :test do
stop
end
end
puts live_loop_names
(Though if you don’t really care about seeing names of threads that are still in the process of stopping, it’s not important of course).