File: parallel_start_and_kill.rb

package info (click to toggle)
ruby-parallel 1.22.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 464 kB
  • sloc: ruby: 1,930; makefile: 4
file content (20 lines) | stat: -rw-r--r-- 480 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true
require './spec/cases/helper'

method = case ARGV[0]
         when "PROCESS" then :in_processes
         when "THREAD" then :in_threads
         else raise "Learn to use this!"
end

options = {}
options[:count] = 2
if ARGV.length > 1
  options[:interrupt_signal] = ARGV[1].to_s
  trap('SIGINT') { puts 'Wrapper caught SIGINT' } if ARGV[1] != 'SIGINT'
end

Parallel.send(method, options) do
  sleep 5
  puts "I should have been killed earlier..."
end