multiprocess-threads 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/multiprocess-threads.rb +18 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3870e87de3afdf0d397b0aee627749259a7bff76b4c9175d9ba09255ade16bce
4
- data.tar.gz: 44f03f5ab17e686685a506097a4924a5e26b82b7b2176d84a611d2a2fa5431c6
3
+ metadata.gz: ee69fe99caca1d5b798549717d5ed50ba94c7a25b3315e6e3cf63d9ea7475faa
4
+ data.tar.gz: 03c7bcb0a0b9f978f548e2e5674454de4aee460e2e12972975ee524b0925d40e
5
5
  SHA512:
6
- metadata.gz: e6169fbb4441dee069e778cfba8d89dda482d6c19fa5f665cd6a295e197083317b04570782c545f0a82b81967dd58b99376f526c09f221ab974d94f168ea7bb5
7
- data.tar.gz: 3af332dd0e97046fc363297950dd5899d675d15d7d9f2517169dcbcfe184848d7590d538478006915f5dbdf490c3388c7f7b189f9de96486c384a01d976a9cdc
6
+ metadata.gz: 6d4a3f3da6b572a73a57f58dc01d7186678136d7d525ff51418c5e8c4a1c81f22913dd486d24b2b4f2a26779ef213cc9042790fd7fbe542190058dc567e5b09f
7
+ data.tar.gz: 06f8397df5186451cfd8b07cf14909e4539383f4f193ae27d33038e143161633e8d87ec4492a0e9f1880068451000680f05f49b3ecc221eb0b370baba9237554
@@ -17,6 +17,8 @@ module MPThreads
17
17
  return nil unless data
18
18
 
19
19
  Marshal.load data # rubocop:disable Security/MarshalLoad
20
+ rescue Interrupt
21
+ nil
20
22
  end
21
23
 
22
24
  def write(data)
@@ -44,9 +46,14 @@ module MPThreads
44
46
  proc_count, thr_count = Parallel.calc_resources count
45
47
  proc_count.times do |i|
46
48
  ::Process.fork do
47
- spawn_threads(thr_count, i, &block).each(&:join)
49
+ workers = spawn_threads(thr_count, i, &block)
50
+ workers.each(&:join)
51
+ rescue Interrupt
52
+ workers.each(&:exit)
48
53
  end
49
54
  end
55
+ rescue Interrupt
56
+ warn 'Exiting'
50
57
  end
51
58
 
52
59
  def spawn_threads(count, proc_i, &block)
@@ -68,3 +75,13 @@ module MPThreads
68
75
  end
69
76
  end
70
77
  end
78
+
79
+ if $PROGRAM_NAME == __FILE__
80
+ mp = MPThreads::Parallel.new do |res|
81
+ puts res
82
+ end
83
+
84
+ mp.work do
85
+ rand(5)
86
+ end
87
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiprocess-threads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Yudin