-
-
Save tobert/435a5ba9fb07de242f273c80ab40ee56 to your computer and use it in GitHub Desktop.
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
def run_in_threads(*tasks) | |
if Rails.env.test? || Rails.env.integration_test? | |
tasks.each(&:call) | |
else | |
tasks.map do |task| | |
Thread.new { | |
ApplicationRecord.connection_pool.with_connection(&task) | |
} | |
end.each(&:join) | |
end | |
end | |
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
run_in_threads( | |
proc { turn_server_power_on }, | |
proc { enable_switch_ports }, | |
proc { set_server_boot_device } | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment