Module: MachineLearningWorkbench::Tools::Execution
- Defined in:
- lib/machine_learning_workbench/tools/execution.rb
Class Method Summary collapse
-
.in_fork(&block) ⇒ Object
Execute block in a fork.
-
.kill_forks ⇒ Object
Call this in an ‘ensure` block after using `in_fork`.
Class Method Details
.in_fork(&block) ⇒ Object
Execute block in a fork. Be sure to check also ‘#kill_forks`
6 7 8 9 10 11 |
# File 'lib/machine_learning_workbench/tools/execution.rb', line 6 def self.in_fork &block raise ArgumentError "Need block to be executed in fork" unless block pid = fork(&block) Process.detach pid $fork_pids << pid end |
.kill_forks ⇒ Object
Call this in an ‘ensure` block after using `in_fork`
14 15 16 |
# File 'lib/machine_learning_workbench/tools/execution.rb', line 14 def self.kill_forks $fork_pids&.each { |pid| Process.kill 'KILL', pid } end |